微信小程序引入绝对路径

编辑: admin 分类: 电脑知识 发布时间: 2023-06-14 来源:互联网
方法1app.js
  1. App({
  2. require: function($uri){return require($uri)},
  3. onLaunch: function () {
  4. },
  5. )}
page.js
  1. const app = getApp();
  2. const echarts = app.require('/ec-canvas/echarts')
  3. Page({
  4. data:{
  5. },
  6. onLoad: function (options) {
  7. },
  8. )}
方法2app.json
  1. {
  2. "resolveAlias":{
  3. "~/*": "/*"
  4. },
  5. "pages": [
  6. "pages/index/index"
  7. ],
  8. }
index.js
  1. import * as echarts from '~/ec-canvas/echarts';
  2. Page({
  3. data:{
  4. },
  5. onLoad: function (options) {
  6. },
  7. )}
【转自:响水网站建设 http://www.1234xp.com/xiangshui.html 复制请保留原URL】