diy_nav.js
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var t = getApp(),
    o = t.globalData.setting;
Component({
  properties: {
    // 这里定义了innerText属性,属性值可以在组件使用时指定
    object: {
      type: Object,
      value: null,
    },
    nav_list: {
      type: Array,
      value: [],
    },
  },
  data: {
    // 这里是一些组件内部数据
    strs:null,
    imghost: o.imghost,
    someData: {}
  },
  ready: function() {
    console.log("ready");
    var g_id = this.data.object.data;
    this.pd_navicon(g_id);
  },
  methods: {
    // 这里是一个自定义方法,判断图片路径,并加载
    pd_navicon:function(g_id){
      var item={};
      var nav_strs=g_id;
      for (var i=0;i<nav_strs.length;i++){
        if (!(nav_strs[i].navicon.indexOf("/public/static/images/model/tag-icon.png"))){
          nav_strs[i].navicon ="../../../../../images/nav-icon.png";
        }
      }
      this.setData({
       nav_list:nav_strs,
      });
    },
    customMethod: function () { },
    //智能跳转
    go_url:function (e) {
       var url=e.currentTarget.dataset.url;
       getApp().goto(url);
    }
  }
})