简体   繁体   English

Vue.js指令在JSP中不起作用

[英]Vue.js directives do not work in JSP

I wish to incorporate some reactive vueJS within my JSP file. 我希望在我的JSP文件中合并一些响应式vueJS。 However the Vue directives are not recognized by the JSP parser and this throws an error: net::ERR_INCOMPLETE_CHUNKED_ENCODING. 但是,JSP解析器无法识别Vue指令,这会引发错误:net :: ERR_INCOMPLETE_CHUNKED_ENCODING。

The example is : 例子是:

<tbody id="items-${job.id}" v-for="item in items"> <tr>Item id = {{item.id}}</tr> ....

Here the v-for directive seems to be a problem. 这里的v-for指令似乎是一个问题。

Anyway you can suggest to solve this ? 无论如何,您可以建议解决此问题? I'd love to use Vue within my JSP. 我很想在我的JSP中使用Vue。

The above code did not work because I was referencing my vue 'el' to the wrong element. 上面的代码不起作用,因为我将vue'el'引用到错误的元素。

The following snippet works and shows that one can use Vue.js with JSPs. 以下代码段可以正常工作,并表明可以将Vue.js与JSP一起使用。

<div id="vue-test">
  <div v-for="item in items" :key="item.id">    
    <p>Item id={{item.id}}, jobItemStatus = {{item.jobItemStatus}}</p>  
  </div>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script>    
var vueItems = new Vue({
    el: '#vue-test',
    data: {
        items : []
    },
    mounted: function(){
        <c:forEach items="${job.jobItems}" var="item" varStatus="status"> 
            this.items = this.items.concat({
                id: ${item.id}, 
                receptionDate : "${item.receptionDate}", 
                deliveryDate : "${item.deliveryDate}", 
                jobItemStatus : "${item.jobItemStatus}"
                });             
        </c:forEach>
    }
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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