最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Vue.js directives do not work in JSP - Stack Overflow

programmeradmin0浏览0评论

I wish to incorporate some reactive vueJS within my JSP file. However the Vue directives are not recognized by the JSP parser and this throws an error: 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.

Anyway you can suggest to solve this ? I'd love to use Vue within my JSP.

I wish to incorporate some reactive vueJS within my JSP file. However the Vue directives are not recognized by the JSP parser and this throws an error: 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.

Anyway you can suggest to solve this ? I'd love to use Vue within my JSP.

Share Improve this question asked Feb 11, 2017 at 11:34 Eva MEva M 6336 silver badges13 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The above code did not work because I was referencing my vue 'el' to the wrong element.

The following snippet works and shows that one can use Vue.js with JSPs.

<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./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>
发布评论

评论列表(0)

  1. 暂无评论