taro router
taro router
https://nervjs.github.io/taro/docs/router.html

bug

import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './index.scss'
import {
AtTabBar,
AtButton,
AtFloatLayout,
} from 'taro-ui'
const log = console.log;
const tabList = [
{
title: 'Home',
text: 8,
},
{
title: 'Modal',
text: 7,
// dot: true,
},
{
title: '通讯录',
dot: true,
},
];
export default class Index extends Component {
/**
* 指定config的类型声明为: Taro.Config
*
* 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
* 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
* 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
*/
config: Config = {
navigationBarTitleText: '首页'
}
constructor () {
super(...arguments)
this.state = {
current: 0,
isOpened: false,
}
}
handleClick (value) {
log(`tab index`, value)
this.setState({
current: value,
});
switch (value) {
case 0:
Taro.navigateTo({
url: '/pages/home/index?id=1&type=test',
})
break;
case 1:
Taro.navigateTo({
url: '/pages/modal/index?id=1&type=test',
})
break;
default:
break;
}
}
handleClose () {
this.setState({
isOpened: false,
})
}
handleOpen () {
this.setState({
isOpened: true,
})
}
componentWillMount () { }
componentDidMount () { }
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () {
const {
current,
isOpened,
} = this.state;
return (
<View className='index'>
<AtTabBar
tabList={tabList}
onClick={this.handleClick.bind(this)}
current={current}
/>
<AtButton
onClick={this.handleOpen.bind(this)}
type='primary'>
modal 按钮
</AtButton>
<AtFloatLayout
title="这是个标题"
isOpened={isOpened}
onClose={this.handleClose.bind(this)}>
这是内容区 随你怎么写这是内容区 随你怎么写这是内容区 随你怎么写这是内容区
随你怎么写这是内容区 随你怎么写这是内容区 随你怎么写
</AtFloatLayout>
</View>
)
}
}
import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './index.scss'
import {
AtButton,
} from 'taro-ui'
const log = console.log;
export default class Home extends Component {
/**
* 指定config的类型声明为: Taro.Config
*
* 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
* 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
* 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
*/
config: Config = {
navigationBarTitleText: '首页'
}
constructor () {
super(...arguments)
this.state = {
current: 0,
isOpened: false,
}
}
gotoIndex () {
Taro.navigateTo({
url: '/pages/index/index',
// url: '/pages/index',
})
}
componentWillMount () { }
componentDidMount () {
log(`this.$router.params`, this.$router.params)
// 输出 { id: 2, type: 'test' }
}
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () {
return (
<View className='home'>
<Text>home page</Text>
<AtButton
onClick={this.gotoIndex.bind(this)}
type='primary'>
返回
</AtButton>
</View>
)
}
}
taro router的更多相关文章
- 小程序 web-view
小程序 web-view https://opendocs.alipay.com/mini/component/web-view https://opendocs.alipay.com/mini/ap ...
- Taro 生命周期
Taro 新加的生命周期 说明 网址 componentDidShow() 在此生命周期中通过 this.$router.params,可以访问到程序初始化参数 https://nervjs.gith ...
- 三、taro路由及设计稿及尺寸单位
一.路由配置 路由配置跟小程序一样,在入口文件的 config 配置中指定好 pages 通过taro API 跳转,详见导航 // 跳转到目的页面,打开新页面 Taro.navigateTo({ u ...
- 迅速上手:使用taro构建微信小程序基础教程
前言 由于微信小程序在开发上不能安装npm依赖,和开发流程上也饱受诟病:Taro 是由京东·凹凸实验室(aotu.io)倾力打造的 多端开发解决方案,它的api基于react,在本篇文章中主要介绍了使 ...
- taro 最佳实践
对 JSX 支持程度补充说明: 不能在包含 JSX 元素的 map 循环中使用 if 表达式 不能使用 Array#map 之外的方法操作 JSX 数组 不能在 JSX 参数中使用匿名函数 暂不支持在 ...
- taro 项目、代码说明
入口文件的生命周期: 入口文件继承自 Component 组件基类,它同样拥有组件生命周期,但因为入口文件的特殊性,他的生命周期并不完整,如下 生命周期方法 作用 说明 componentWillMo ...
- Taro:使用taro完成小程序开发
前言:taro是一个可以很好实现一次开发,多端统一的框架,本文只介绍它小程序端开发的一些内容.小程序项目搭建gitup已经有很清楚的说明:https://github.com/NervJS/taro ...
- React-Native转小程序调研报告:Taro & Alita
一. 我们的要求 期望的要求 基于React语法,将RN项目转化为小程序项目 该小程序能同时在 微信小程序 和 支付宝小程序这两个平台运行 底线要求 底线是能转成微信小程序,因为目前来说,因为微信先发 ...
- 每天一点点之 taro 框架开发 - taro路由及传参
1.路由 taro的路由是自带的,不需要我们额外配置,只需要我们在app.js下config中配置pages即可 class App extends Component { config = { pa ...
随机推荐
- C#编写一个在asp.net core 3.1下的简单的corn模式的计划任务和一个更简单的定时器类
asp.net core 下,新增了一个BackgroundService用来实现能在后台跑一个长久运行的任务,因此,也可以用来替换掉原来使用的static的Timer组件, Timer组件主要有以下 ...
- Excel常见后缀名
1.格式.xlsx:excel2007-2016版默认的文件格式,不能有宏: 2.格式.xls:excel97-2003版,可以有宏: 3.格式.csv:以逗号分隔的文本文件,便于兼容其他程序,只保存 ...
- 函数式编程(__slots__)
正常情况下,当我们定义了一个class,创建了一个class的实例后,我们可以给该实例绑定任何属性和方法,这就是动态语言的灵活性.先定义class: class Student(object): pa ...
- Spring boot 异步线程池
package com.loan.msg.config; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandle ...
- 获取java栈异常
package com.loan.modules.extbiz.in.rabbitmq.util; import java.io.PrintWriter; import java.io.StringW ...
- UML——RUP(Rational Unified Process)
一.宏观导图 二.论细节 RUP(Rational Unified Process)统一软件过程,是指要达到一个指定的目标而采取的一些系列有序的步骤,其目的是高效.准时地提交一个满足业务需求的软件产品 ...
- Pytest(2)使用和调用方法
Pytest执行用例规则 Pytest在命令行中支持多种方式来运行和选择测试用例 1.对某个目录下所有的用例 pytest 2.对模块中进行测试 pytest test_mod.py 3.对文件夹进行 ...
- python工业互联网应用实战5—Django Admin 编辑界面和操作
1.1. 编辑界面 默认任务的编辑界面,对于model属性包含"choices"会自动显示下来列表供选择,"datetime"数据类型也默认提供时间选择组件,如 ...
- 【uva 120】Stacks of Flapjacks(算法效率--构造法+选择排序思想)
题意:有N张正在锅里的一叠煎饼,每张都有一个数字,代表其大小.厨师每次可以选择一个数k,把从锅底开始数第k张上面的煎饼全部翻过来,即原来在上面的煎饼现在到了下面.要求设计一种方法使得所有煎饼按照从小到 ...
- hdu 4521 小明系列问题——小明序列 线段树
题意: 给你一个长度为n的序列v,你需要输出最长上升子序列,且要保证你选的两个相邻元素之间在原数组中的位置之差大于d 题解: 这个就是原来求最长上升子序列的加强版,这个思路和最长上升子序列的差不多 ...