首页 > Web开发 > 详细

Chrome 调用vue.js 记录

时间:2018-05-29 00:53:07      阅读:266      评论:0      收藏:0      [点我收藏+]

一、今晚遇到一个问题,就是不能直接在 html 直接调用 js 代码的问题

二、会出现如下错误:

    Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-    vKuX0yKlIAX3ZzZ9/PIUq7x1z425uZLu4glsP+4fqXM='), or a nonce ('nonce-...') is required to enable inline execution.

三、解决方法,就是将 js 代码写成单独的文件,然后包含进去即可。

    # index.html
    <!DOCTYPE html>
    <html>
      <head>
        <script src="js/vue.min.js"> </script>
      </head>
  
      <body>
        <div id="chen_test_id1">
          <p>{{ message }}</p>
        </div>
        <script src="js/test.js"> </script>
      </body>

    </html>
    // js/test.js
    src="js/vue.min.js">
    new Vue({
      el: '#chen_test_id1',
      data: {
        message: 'Hello Vue.js!'
      }
    })

Chrome 调用vue.js 记录

原文:https://www.cnblogs.com/chenfulin5/p/9102878.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!