繁体   English   中英

如何使用 CSS 属性选择器 select vue js el?

[英]How to select the vue js el using CSS attribute selector?

我有这个 HTML:

<div data-identifier='app'>
   ...
</div>

我有这个 Vue js 代码:

      var app = new Vue({
            el: '[data-identifier]',
            data: {
                
            },
            methods: {

            }
        });

但似乎 Vue 不理解[data-identifier] CSS 选择器。

如何在 Vue js 中使用属性 CSS 选择器?

它应该如下所示工作:

 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM