使用VScode js模块开发学习中 <script type=‘module‘>引入遇到问题

	
		<script type = 'module' >
		    import {title} from './hd.js'
		</script>
		

Hd.js文件引入路径没有问题
let title = ‘后盾人’;
export {title}

报错
Access to script at
‘file:///D:/%E5%AD%A6%E4%B9%A0/%E6%B5%B7%E8%B1%9A%E6%97%A5%E8%AE%B0%20javascript/%E6%A8%A1%E5%9D%97%E5%8C%96%E5%BC%80%E5%8F%91/hd.js’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
hd.js:1 Failed to load resource: net::ERR_FAILED
模块的基本使用.html:1 Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: file:///D:/%E5%AD%A6%E4%B9%A0/%E6%B5%B7%E8%B1%9A%E6%97%A5%E8%AE%B0%20javascript/%E6%A8%A1%E5%9D%97%E5%8C%96%E5%BC%80%E5%8F%91/hd.js

解决方式
解决办法 VScode 前端(html文件)以服务器模式打开
在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值