This article mainly introduces the WeChat appletQuoteOther js file implementation code related information, friends in need can refer to
WeChat How does a small program reference other js files
1. We first create a common.js file and write our program in common.js,
function myfunc() { console.log("myfunc...."); }
module.exports.myfunc = myfunc; This exposes interface. It cannot be referenced if it is not exposed here.
is in the file domain js Inside
var common = require("../../common.js"); to link over, just linking over is not enough!
var app; var common = require("../../common.js"); Page({ data:{ }, onLoad:function() { app = getApp(); this.setData({version:app.globalData.appName}); common.myfunc(); //最后我们需要执行才能生效! } })
[Related recommendations]
1. How to call global JS in WeChat development?
2. JS dynamic modification style of WeChat development
3. Example tutorial of life cycle function of WeChat development
The above is the detailed content of Detailed explanation of examples of referencing other js files in WeChat development. For more information, please follow other related articles on the PHP Chinese website!