受欢迎的博客标签

step 1.写一个模块

代码:

//小程序module.exports 模块化
/**
 * 配置集合名称
 **/
var friendsCircleCollection = 'friendsCircle';


//模块化
module.exports = {
  friendsCircleCollection: friendsCircleCollection
}

 

step 2:引用模块

// miniprogram/pages/friendsCircle/index/index.js
//朋友圈项目:https:/ / github.com / xiaozhaoqi / moments

var config = require("../modules/config.js")
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info: false,
    bgiURL: '',
    avatarUrl: '',
    nickName: '',
    text: '',
    page: 1,
    pageSize: 10,
    hasMoreData: true,
    stateList: [],
    showMenu: [],
    formImageId: '',
    imageStamp: 0,
    submitDisabled: false,
    friendsCircleCollection: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    
    this.setData({
      friendsCircleCollection: config.friendsCircleCollection
    });

  },

 

结果如下