H5页面,常用浏览器访问兼容性测试

全局安装BrowserSync

npm install -g browser-sync

运行命令不起作用 解决方案:

局部安装browser-sync

npm install -g browser-sync (项目中局部安装  npm install --save-dev browser-sync)

然后在你的package.json中,你会看到新的依赖,然后配置你的

"scripts": {
          
   
    "dev": "browser-sync start --server --files "*.html, css/*.css, js/*.js"",
    "start": "npm run dev"
  },

接下来,你在cmd下的项目目录中,输入npm run dev 浏览器

好吧,到底哪里出问题了

localhost/:1 Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:7 Refused to execute inline script because it violates the following Content Security Policy directive: "default-src self". Either the unsafe-inline keyword, a hash (sha256-ThhI8UaSFEbbl6cISiZpnJ4Z44uNSq2tPKgyRTD3LyU=), or a nonce (nonce-...) is required to enable inline execution. Note also that script-src was not explicitly set, so default-src is used as a fallback.

localhost/:1 Failed to load resource: the server responded with a status of 404 (Not Found)

翻译:

拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“default-src ‘self’”。要启用内联执行,需要一个散列(‘sha256ThhI8UaSFEbbl6cISiZpnJ4Z44uNSq2tPKgyRTD3LyU=’)或一个nonce> (‘nonce-…’)。还要注意,script-src’没有被显式地设置,因此’default-src’被用作回退。

参考文档:

经验分享 程序员 微信小程序 职场和发展