需要满足以下三个条件:

1、高版本的Chrome ,总而言之越新越好……,其他浏览器请参考:https://caniuse.com/#search=import

2、必须在服务器环境下才能运行,譬如apache或者nginx,或者大部分语言都能开启的服务环境(我这里用phpstudy的Nginx环境来测试)

3、需要在 script 中加入 type = 'module'

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="app"></div>
</body>
<script type='module'>
import test from './test.js'
console.log(20181221204836, test) // {a: 123 }
</script>
</html>

test.js

export default {
a: 123
}

效果图如下:

最新文章

  1. [MongoDB]Mongo基本使用:
  2. HashBytes(Transact-SQL)
  3. javascript的this
  4. WinForm程序打包说明
  5. GDB调试器使用总结
  6. UIScrollView做循环图片
  7. njust oj triple 莫比乌斯反演
  8. LA2965 n个数中选出最多个数异或和为0
  9. 网时|ipone8爆冷,我的服务器空欢喜一场
  10. (十五)UITableViewCell的常见属性
  11. Java并发编程系列-AbstractQueuedSynchronizer
  12. mysql基本命令总结
  13. Python用起来极度舒适的强大背后
  14. Hbase使用MapReduce编程导出数据到HDFS
  15. VitualBox安装linux记录
  16. 函数和常用模块【day04】: 总结(十二)
  17. Python扩展之类的魔术方法
  18. SSH学习之四 OpenSSH安全
  19. IOS中手势UIGestureRecognizer
  20. Drainage Ditches(POJ1273+网络流+Dinic+EK)

热门文章

  1. 搭建持续集成单元测试平台(Jenkins+Ant+Java+Junit+SVN)
  2. 实验室报告:VMware vSphere Data Protection
  3. Git诞生
  4. Java中的List
  5. merge-two-sorted-lists合并链表
  6. 【shell】各种括号()、(())、[]、[[]]、{}的使用
  7. 使用springMVC和Jquery实现JSONP
  8. T550 HiDPI Ubuntu 16.04安装流水帐
  9. Android API之android.content.BroadcastReceiver
  10. web安全之渗透测试