Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

vue 定义组件的时候怎么把style样式也写到组件定义内部,而且不影响其他组件?

vue定义组件时,可以将专属方法定义到methods之中,但样式呢?也可以类似定义吗?样式是有scoped属性的,但我没有找到定义到Vue.componue的方法.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Vue.component('my-component', {
  template: '<div>hello world</div>'
})

上面这样定义组件没法写样式,因为没有东西去编译css。

.vue中能写样式是因为有loader去编译。
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...