vue引用js文件,以及報錯net::ERR_ABORTED問題


第一種操作 Dom引入js:

export default { mounted() { const s = document.createElement('script'); s.type = 'text/JavaScript'; s.src = '你的需要的js文件地址'; document.body.appendChild(s); }, }

第二種使用 createElement 方法:
export default { components: { 'remote-js': { render(createElement) { return createElement( 'script', { attrs: { type: 'text/JavaScript', src: '你的需要的js文件地址', }, }, ); }, }, }, } // 使用 <remote-js></remote-js> 在頁面中調用

當我在使用第一種方式進行js文件引入時,出現net::ERR_ABORTED報錯信息,經過檢查發現,引入的js文件存放的位置不正確,應該將js文件放到static文件夾下,再進行引用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM