【发布时间】:2022-07-16 09:40:13
【问题描述】:
我正在学习 Vue js。我使用 CDN 中包含的 Vue 创建了一个应用程序,我想知道如何向其中添加 <style>。
我可以将模板写成template: `<div>Vue js 3</div>` ,但是"style": " ... "字符串可以写成同样的方式添加到组件JS吗?
export default {
data() {
return {
count: 0
}
},
methods: {
increment() {
this.count++
},
},
template: `<button @click="increment">count is: {{ count }}</button>`,
// can style be written like the template above? For example, I tried:
style: {
button {
background: red;
}
},
mounted() {
console.log(`The initial count is ${this.count}.`)
},
}
【问题讨论】:
-
你能提供你的组件链接吗?你想编写单个文件组件吗?
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: javascript node.js vue.js vue-component vuejs3