写了一个很简单的table的组件
var printer_data = {
printers: [],
check_item: null,
header_names: [{name:"序号",width:"5%"},{name:"打印机",width:"85%"},{name:"设置",width:"10%"}]
};
Vue.component('printer', {
template: '{{ header.name }} {{index+1}} {{printer.name}} {{printer.default_printer}} ',
data: function () {
return printer_data;
},
methods:{
d_click:function(index){
printer_data.check_item = index;
}
}
});
使用的时候会报
vue.js:525 [Vue warn]: failed to compile template:
- invalid expression: :class="{ list-active: index == check_item }"
在组件中不能这样使用class吗?
那应该如何写呢?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
list-active 要用单引号包裹一下