taro中子父传值
其实网上很多方法,我这只是一个简单的demo,废话不多说直接上代码
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './index.less'
//子组件
class Child extends Component{
constructor(props) {
super(props);
this.state = ({
})
}
handleVal (event) {
this.props.handleEmail(event.target.value);
}
render (){
return (
<div>
请输入邮箱:<input style="width:200px;height:30px;font-size:18px;" ref="emailDom" onChange={this.handleVal.bind(this)} />
</div>
)
}
};
export default class Index extends Component {
constructor(props) {
super(props);
this.state = {
email:"火星黑洞"
}
}
handleEmail1(date){
this.setState({
email:date
})
}
config = {
navigationBarTitleText: '首页'
}
componentWillMount () { }
componentDidMount () { }
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () {
return (
<div className='index'>
<h3>子父传值</h3>
<Child name="email" handleEmail={this.handleEmail1.bind(this)}/>
<div>用户邮箱:{this.state.email}</div>
</div>
)
}
}
然后执行:cnpm run dev:h5
页面效果是:

taro中子父传值的更多相关文章
- vue 实现子向父传值
父组件 <template> <div id="app"> <child @onChange='onChildValue'></child ...
- react hooks子给父传值
子给父传值需要通过事件方法来传值,这里我们子组件是触发了一个点击事件传值: <Button onClick={()=>setshowregister(false)}>注册</B ...
- uniapp和vue 父向子传值、传方法及子向父传值。(一看就会超级简约)
1.父向子传值:父组件在引用子组件时通过自定义属性绑定自身需要传递的值(数据),子组件用props:[ '自定义' ]接收即可使用(props里数据是只读模式).(简约版:子绑定父的属性并用pro ...
- vue中子组件传值给父组件
index.js 子组件 父组件
- vue子向父传值
要弄懂子组件如何向父组件传值,需要理清步骤 子组件向父组件传值的步骤 一:子组件在组件标签上通过绑定事件的方式向父组件发射数据 <!--html--><template id=&qu ...
- 每天一点点之 taro 框架开发 - taro调用组件传值
1.调用组件 组件文件 import Taro, { Component } from '@tarojs/taro' import { View } from '@tarojs/components' ...
- js中子父页面数据传递与方法调用
A父页面 ,B为子页面 1.父页面调用子页面 A中调用B中方法:self.frames[iframeName].BFunction(); 注:iframeName:为父页面中iframe的name属性 ...
- iframe中子父窗口互调的js方法
转载自:http://www.cnblogs.com/chinafine/archive/2011/09/15/2177746.html 一.父窗口调用iframe子窗口方法 1.HTML语法:< ...
- iframe中子父页面跨域通讯
目录 #跨域发送信息 #跨域接收信息 #示例Demo 在非跨域的情况下,iframe中的子父页面可以很方便的通讯,但是在跨域的情况下,只能通过window.postMessage()方法来向其他页面发 ...
随机推荐
- android6.0 Activity(四) Surface创建
原文:http://blog.csdn.net/luoshengyang/article/details/8303098.原文代码比較老了,可是核心不变.在原文基础上改动了一些代码,以及增加自己 ...
- python3命令行ImportError: No module named 'xxxx'的问题
主要原因:启动脚本不在当前目录下,无法找到上一层 在pycharm写好的脚本程序,在命令行无法运行,报错 Traceback (most recent call last): File "t ...
- 【转载】浅析依赖倒置(DIP)、控制反转(IOC)和依赖注入(DI)
原文地址 http://blog.csdn.net/briblue/article/details/75093382 写这篇文章的原因是这两天在编写关于 Dagger2 主题的博文时,花了大量的精力来 ...
- PHP常见问题整理
1. 如何在Windows下配置PHP开发环境? (1)下载并安装Apache,设置服务器的侦听端口.编辑Apache安装目录下的conf子目录中的httpd.conf文件,定位到DocumentRo ...
- 写文件的工具类,输出有格式的文件(txt、json/csv)
import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io. ...
- 用scrapy框架爬取映客直播用户头像
1. 创建项目 scrapy startproject yingke cd yingke 2. 创建爬虫 scrapy genspider live 3. 分析http://www.inke.cn/ ...
- go关键字之type用法
1.定义结构体 type Student struct { name string code int } 2.类型别名 type i int64 var age i = 30 ...
- error MSB3073: 命令“copy /y
编译VC程序时候报错:error MSB3073: 命令“copy /y 查看: 项目的属性->配置属性->生成事件->后期生成事件->命令行: copy /y "$ ...
- 使用 Java 程序写文件时,记得要 flush()
使用 Java 程序往磁盘写文件时碰到了这样的问题:文件写不全. 假如内容(StringBuffer/StringBuilder)有 100W 个字符,但是通过 Java 程序写到文件里的却不到 10 ...
- git bash here右键菜单
Windows Registry Editor Version 5.00 ; Open files[HKEY_CLASSES_ROOT\*\shell\gitbash]@="gitbash& ...