navigator 组件,url 属性,值不能含有 url 字符
发布于 6 年前 作者 kpan 4102 次浏览 来自 问答
<block wx:for="{{menus}}" wx:key="identifier">
    <navigator url="{{item.url}}" open-type="navigate" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
      <view class="weui-cell__bd">{{item.name}}</view>
      <view class="weui-cell__ft weui-cell__ft_in-access"></view>
    </navigator>
</block>

menus 是个数组,内容如下

[
      {
        "name": "统计",
        "identifier": "statistics",
        "url": "/pages/statistics/index"
      },
      {
        "name": "关于我",
        "identifier": "about",
        "url": "/pages/about/index"

      },

]

把 url 换成 path 就好了,这里解析的时候可能有 bug

[
      {
        "name": "统计",
        "identifier": "statistics",
        "path": "/pages/statistics/index"
      },
      {
        "name": "关于我",
        "identifier": "about",
        "path": "/pages/about/index"
      },
]
回到顶部