React Js string字符串转换为html dom
来源:互联网 发布:麦课网络通识学院 编辑:程序博客网 时间:2024/06/13 22:23
如果你没有走网络请求,也就是没有render两次,就使用注释掉的两个方法即可。或者两个都写一遍。
/** * Created by wuyakun on 2017/4/27. */import React from 'react';class GoodsDetail extends React.Component { constructor(props) { super(props); this.state = { goods_desc: '', }; } //为什么会走更新的,就是因为Goods render了两次(初始-网络数据) // componentWillMount() { // this.setState({ // goods_desc: this.props.goods_desc ? this.props.goods_desc : '', // }); // } // 组件更新props componentWillReceiveProps(value) { this.setState({ goods_desc: value.goods_desc ? value.goods_desc : '', }); } // componentDidMount() { // document.getElementById("goods_detail_content").innerHTML = this.state.goods_desc; // } //更新完毕 componentDidUpdate() { document.getElementById("goods_detail_content").innerHTML = this.state.goods_desc; } render() { return ( <div> <div className="pro_detial"> <h3><i />课程详情</h3> <div className="pro_con"> <div id="goods_detail_content"/> </div> </div> </div> ); }}export default GoodsDetail;
0 0
- React Js string字符串转换为html dom
- html转换为string
- React Js html 正则替换 转换为 jsx 写法 style=" {{
- jquery对象怎么转换为html对象(也就是js的dom对象)
- jquery对象怎么转换为html对象(也就是js的dom对象)
- js字符串转换为对象
- js 字符串转换为数字
- 从textarea中空格、逗号、换行转换为逗号分隔的字符串 js string.split
- 将string字符串转换为Enum
- 将String字符串转换为Class类
- 将 System::String 转换为标准字符串
- 将JSON字符串转换为String对象
- 把String字符串转换为Int数组
- 将list转换为String字符串
- 将string字符串转换为array数组
- 转换一个String字符串为byte数组
- 将String字符串转换为GB2312编码
- 字符串转换为HTML字符的方法
- 一些关于蛋白质序列分类的总结
- ms sql server 2个数据库服务器之间进行操作
- 如何用github给开源贡献代码
- 51nod 1413 权势二进制(数学)
- 正则表达式的学习笔记
- React Js string字符串转换为html dom
- 首次接触easyAR到unity的实现
- <名词解释>算法&时间复杂度
- Storm基本概念
- jdbcTemplate查询的三种回调
- 解决锐捷校园网环境下VMware虚拟机无法上网问题
- Win7+Pycharm+Python+Selenium,环境搭建总结
- kali安装 vmtools
- 一个想法照进现实-《IT连》创业项目:创业时该不该用新手程序员