在……里面
https://codesandbox.io/s/compassionate-gagarin-qxp98?file=/src/components/GenericItem.vue:1921-1957
我正在尝试显示一个需要设置样式的模式。使用
<style scoped>
@import "../styles/modal-style.css";
</style>不加载适当的样式,也不粘贴
https://codesandbox.io/s/compassionate-gagarin-qxp98?file=/src/styles/modal-style.css:0-1064
添加到style标记中。
我们的想法是得到类似这样的东西
https://codesandbox.io/s/sleepy-tdd-jrrgg?file=/index.html:122-181
但是这个模式是一个单一的文件组件。
为什么vue不加载样式?
发布于 2021-07-09 04:43:17
在这种情况下,您应该在您的webpack配置文件中创建别名,如下所示:
... your webpack config ...
configureWebpack: {
resolve: {
alias: {
'~styles': path.resolve(_dirname, 'path/to/your/styles.css')
}
}
}您的别名现在将是全局的,因此您将能够这样做:
<style scoped>
@import '~styles';
</styles>https://stackoverflow.com/questions/68307036
复制相似问题