【发布时间】:2017-11-20 00:44:22
【问题描述】:
我想在我的组件上设置一个没有任何值的属性。例如:
<my-button primary>Save</my-button>
我在我的组件的props 中声明primary:
Vue.component("my-button", {
props: ["primary"],
template: "<button v-bind:class='{primary: primary}'><slot></slot></button>"
})
不幸的是,它不起作用。 primary 属性为 undefined 且未应用该类。
【问题讨论】:
标签: properties attributes vue.js vuejs2 vue-component