Home >WeChat Applet >Mini Program Development >How to call global JavaScript in this scope

How to call global JavaScript in this scope

巴扎黑
巴扎黑Original
2017-09-12 10:39:421333browse

微信小程序本作用域下调用全局JS详解

本地wxml文件

<view>
app版本:pw_version
</view>

本地js文件

var app;
Page({
data:{
},
onLoad:function() {
app = getApp();
this.setData({version:app.globalData.appName});
}
})

全局js文件

//app.js
App({
globalData:{
appName:"hcoder"
},
test:function () {
console.log("ok");
}
})

The above is the detailed content of How to call global JavaScript in this scope. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn