Taro使用小结

1.不需要注册路由,只需要在app.js里写上文件对应的路径即是路由:

config = {
    pages: [
      'pages/case/index',
      'pages/index/index',
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'black'
    }
  }

访问路径:http://127.0.0.1:10086/#/pages/solution/index

2.图片引用使用

<Image className='content-catalog-icon' src={require('../../assets/images/solution/icon_P01.png')}></Image>

但如果是使用数组循环时,需要在数组中使用require,而不是html代码中

 

//数据
contentList:[
        {
            id : "safe",
            name : "云安全解决方案",
            icon : require("../images/solution/icon_P01.png"),
            articleList : [{
                articleId:1,
                title:"111111",
                url: 'https://mp.weixin.qq.com/mp/homepage?__biz=MjM5MjcyMjU5NA%3D%3D&hid=11&sn=0a578331a3065e6bf0ad2262c7db6a27&scene=18'
            }]

        },
       
    ]


//js
import solutionList from '../../assets/json/solutions'

render () {
   // 列表
    const contentList = (
      solutionList.contentList.map((item,index) => {
        let content = (<View className="content" id={item.id}>
        <View className="content-catalog">
          <Image className='content-catalog-icon' src={item.icon}></Image>
          <View className="content-catalog-txt">{item.name}</View>
        </View>
        </View>)

        return content
      })
    )


<View>{contentList} </View>

}









 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值