一、今晚遇到一个问题,就是不能直接在 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