cordova中使用vue,主要是CSP(Content Security Policy)的问题. 最简单的应对是使用CSP版本的vue. 可惜只有1.x的vue才支持. 1.x的最后一个csp版本是1.0.28, 下载链接, 该版本github地址
另有一篇文章讲怎么使用非CSP版本的vue: building-a-mobile-app-with-cordova-vuejs
但我使用后发现并不奏效...罢了..

如果要使用vue2.x,根据官方的描述:

CSP environments

Some environments, such as Google Chrome Apps, enforce Content Security Policy (CSP), which prohibits the use of new Function() for evaluating expressions. The full build depends on this feature to compile templates, so is unusable in these environments.
On the other hand, the runtime-only build is fully CSP-compliant. When using the runtime-only build with Webpack + vue-loader or Browserify + vueify, your templates will be precompiled into render functions which work perfectly in CSP environments.

也就是说使用webpack编译过的.vue就可以自带CSP属性.

标签: none 阅读量: 1235

添加新评论