[英]How to select the vue js el using CSS attribute selector?
I have this HTML:我有这个 HTML:
<div data-identifier='app'>
...
</div>
And I have this Vue js code:我有这个 Vue js 代码:
var app = new Vue({
el: '[data-identifier]',
data: {
},
methods: {
}
});
But it seems that Vue does not understand [data-identifier]
CSS selector.但似乎 Vue 不理解[data-identifier]
CSS 选择器。
How can I use attribute CSS selector with Vue js?如何在 Vue js 中使用属性 CSS 选择器?
It should work as shown below:它应该如下所示工作:
var app = new Vue({ el: '[data-identifier]', data: { msg:"hello" }, methods: { } });
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div data-identifier='app'> {{msg}} </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.