Uniapp引入外部js的方法:首先新建一个indexl文件,引入外部js,代码为【<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>】;然后打开manifest文件。

本教程操作环境:windows7系统、uni-app2.5.1版本,Dell G3电脑该方法适用于所有品牌电脑。
推荐(免费):uni-app开发教程
Uniapp引入外部js的方法:
首先新建一个indexl文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
})
</script>
<link rel="stylesheet" href="<%= htmlWebpackPlugin.options.baseUrl %>static/index.css" />
<!-- 引入外部js -->
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
// 获取ip
console.log(returnCitySN["cip"]+','+returnCitySN["cname"])
</script>
</head>
<body>
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>然后打开manifest.json
"h5" : {
"devServer" : {
"port" : 8000,
"disableHostCheck" : true,
},
// 这里引入html
"template" : "index.html",
"optimization" : {
"treeShaking" : {
"enable" : true
}
}
}相关免费学习推荐:编程视频
以上就是Uniapp怎么引入外部js的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号