Get the App
SLTechnology News&Howtos  ›  Development  › 

How does WeChat Mini Programs quote other js files

Shulou Source: shulou.com Published: 2022-06-03 15:41:57 11月14日 Update

This article mainly introduces WeChat Mini Programs how to quote other js files, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

How does WeChat Mini Programs quote other js files

1. Let's first set up a common.js file and write our program in common.js

Function myfunc () {console.log ("myfunc....");}

Module.exports.myfunc = myfunc; exposes the interface in this way, and cannot be referenced here without exposure

In the file domain js

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 (); / / finally we need to execute to take effect! }}) Thank you for reading this article carefully. I hope the article "how WeChat Mini Programs quotes other js documents" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Documents programs articles links no value interest at the same time interfaces more friends knowledge editing industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Shulou Information NVidia Shulou Tech Info