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

How to call global JavaScript in this scope

巴扎黑
Release: 2017-09-12 10:39:42
Original
1347 people have browsed it

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

本地wxml文件

<view>
app版本:pw_version
</view>
Copy after login

本地js文件

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

全局js文件

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template