使用https://github.com/matfish2/vue-tables-2和 Vue 版本 2,我似乎无法在 JSX 上绑定 click 事件(在模板-> 编辑上):
var tableColumns = ['name', 'stock', 'sku', 'price', 'created_at']
var options = {
compileTemplates: true,
highlightMatches: true,
pagination: {
dropdown: true,
chunk: 10
},
filterByColumn: true,
texts: {
filter: 'Search:'
},
datepickerOptions: {
showDropdowns: true
},
templates: {
edit: function (h, row) {
return <button v-on:click={this.showItem(row.id)} class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-edit"></i></button>
},
delete: function (h, row) {
return <a href="javascript:void(0);" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-erase"></i></a>
}
}
}
export default {
name: 'ItemList',
data: function () {
return {
options: options,
columns: tableColumns
}
},
methods: {
showItem: function (id) {
console.log(id)
}
}
}
更改为 JSX on-click
,但 Vue 无法识别。
.babelrc
已经有:
{
"presets": ["es2015"],
"plugins": [
"transform-runtime",
"transform-vue-jsx"
]
}