chrome扩展程序使用vuejs出现问题 财富值84

2016-10-12 13:45发布

刚学着写chrome的插件,循环历史记录的时候想用vuejs试一试列表循环,结果发现vuejs并没有报错但是数据位置都变成了空白的。

下面是简化的内容:

index.html:

<body>     <div id="app">         <h1 id="pageTitle">##{{title}}</h1>     </div>     <script src="jquery.js"></script>     <script src="vue.min.js"></script>     <script src="app.js"></script>    </body>

app.js:

console.log($("#pageTitle").text()) //结果为 "##{{title}}" var app = new Vue({     el:"#app",     data:{       title:"新的页面"       } }) console.log(app.title) // 结果为 "新的页面"  console.log($("#pageTitle").text()) //结果为 "##",理想结果应该是"##新的页面"
付费偷看设置
发送
1条回答

chrome extension 的运行环境有一些特殊要求,称为 Content Security Policy (CSP),使得通常的 vue 不能被正常使用。如果用的是 vue 1.x,那么可以下载 csp 版本,在 这里。如果是 2.x 版本,请参考官网文档的这一段

一周热门 更多>