活久见: 原来 Chrome 浏览器支持 Import from 语法
2024-10-19 12:47:40
需要满足以下三个条件:
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
}
效果图如下:
最新文章
- [MongoDB]Mongo基本使用:
- HashBytes(Transact-SQL)
- javascript的this
- WinForm程序打包说明
- GDB调试器使用总结
- UIScrollView做循环图片
- njust oj triple 莫比乌斯反演
- LA2965 n个数中选出最多个数异或和为0
- 网时|ipone8爆冷,我的服务器空欢喜一场
- (十五)UITableViewCell的常见属性
- Java并发编程系列-AbstractQueuedSynchronizer
- mysql基本命令总结
- Python用起来极度舒适的强大背后
- Hbase使用MapReduce编程导出数据到HDFS
- VitualBox安装linux记录
- 函数和常用模块【day04】: 总结(十二)
- Python扩展之类的魔术方法
- SSH学习之四 OpenSSH安全
- IOS中手势UIGestureRecognizer
- Drainage Ditches(POJ1273+网络流+Dinic+EK)
热门文章
- 搭建持续集成单元测试平台(Jenkins+Ant+Java+Junit+SVN)
- 实验室报告:VMware vSphere Data Protection
- Git诞生
- Java中的List
- merge-two-sorted-lists合并链表
- 【shell】各种括号()、(())、[]、[[]]、{}的使用
- 使用springMVC和Jquery实现JSONP
- T550 HiDPI Ubuntu 16.04安装流水帐
- Android API之android.content.BroadcastReceiver
- web安全之渗透测试