我是靠谱客的博主 结实期待,这篇文章主要介绍Uniapp怎么引入外部js,现在分享给大家,希望可以做个参考。

本教程操作环境:windows7系统、uni-app2.5.1版本,Dell G3电脑该方法适用于所有品牌电脑。

推荐(免费):uni-app开发教程

Uniapp引入外部js的方法:

首先新建一个indexl文件

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!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

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
"h5" : { "devServer" : { "port" : 8000, "disableHostCheck" : true, }, // 这里引入html "template" : "index.html", "optimization" : { "treeShaking" : { "enable" : true } } }
登录后复制

以上就是Uniapp怎么引入外部js的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是结实期待最近收集整理的关于Uniapp怎么引入外部js的全部内容,更多相关Uniapp怎么引入外部js内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(119)

评论列表共有 0 条评论

立即
投稿
返回
顶部