如何在data="{{categoryInfo:categoryInfo0}}"中拼接参数?
发布于 6 年前 作者 guiying99 4685 次浏览 来自 问答

请问如何在 data="{{categoryInfo:categoryInfo0,host:host}}

<template is="categorydetail" data="{{categoryInfo:categoryInfo0,host:host}}"/> 
想这样调用{{'categoryInfo'+currentMenuIndex}}
<template is="categorydetail" data="{{categoryInfo:['categoryInfo'+currentMenuIndex],host:host}}"/>
currentMenuIndex 这个值是动态变动的
请问我这个传参应该如何拼接呢?
3 回复

你的categoryInfo是个数组吗,为啥不这样:

<block wx:for="{{categoryInfo}}" wx:key="id">
  <template is="categorydetail" data="{{categoryInfo:item,host:host}}"/>
</block>

不是是object

categoryInfo0 是一个变量吗?

回到顶部