chrome console报错如下:
home.html:33 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem:". Either the 'unsafe-inline' keyword, a hash ('sha256-bhHHL3z2vDgxUt0W3dWQOrprscmda2Y5pLsLg4GF+pI='), or a nonce ('nonce-...') is required to enable inline execution.
解决方式如下:
1.js不可直接写到html里,要用引入方式
<script src="home.js"> </script>
2.html dom里不能用onclick注册事件,要用id。
<button id="show_passwd">show passwd</button>
3.在外部js里,注册事件
function show_passwd(){
document.getElementById("passwd").style.display= 'block'
}
let btnOutPut = document.getElementById("show_passwd");
btnOutPut.onclick = show_passwd;