(精华)2020年7月30日 微信小程序 富文本和文本的使用
发布日期:2021-06-29 15:08:32
浏览次数:3
分类:技术文章
本文共 2801 字,大约阅读时间需要 9 分钟。
富文本
const htmlSnip =``const nodeSnip =`Page({ data: { nodes: [{ name: 'div', attrs: { class: 'div_class', style: 'line-height: 60px; color: red;' }, children: [{ type: 'text', text: 'You never know what you're gonna get.' }] }] }})`Page({ onShareAppMessage() { return { title: 'rich-text', path: 'page/component/pages/rich-text/rich-text' } }, data: { htmlSnip, nodeSnip, renderedByHtml: false, renderedByNode: false, nodes: [{ name: 'div', attrs: { class: 'div_class', style: 'line-height: 60px; color: #1AAD19;' }, children: [{ type: 'text', text: 'You never know what you\'re gonna get.' }] }] }, renderHtml() { this.setData({ renderedByHtml: true }) }, renderNode() { this.setData({ renderedByNode: true }) }, enterCode(e) { console.log(e.detail.value) this.setData({ htmlSnip: e.detail.value }) }})Title
Life is like a box of chocolates.
通过HTML String渲染 { { htmlSnip}} 通过节点渲染 { { nodeSnip}}
文本
const texts = [ '2011年1月,微信1.0发布', '同年5月,微信2.0语音对讲发布', '10月,微信3.0新增摇一摇功能', '2012年3月,微信用户突破1亿', '4月份,微信4.0朋友圈发布', '同年7月,微信4.2发布公众平台', '2013年8月,微信5.0发布微信支付', '2014年9月,企业号发布', '同月,发布微信卡包', '2015年1月,微信第一条朋友圈广告', '2016年1月,企业微信发布', '2017年1月,小程序发布', '......']Page({ onShareAppMessage() { return { title: 'text', path: 'page/component/pages/text/text' } }, data: { text: '', canAdd: true, canRemove: false }, extraLine: [], add() { this.extraLine.push(texts[this.extraLine.length % 12]) this.setData({ text: this.extraLine.join('\n'), canAdd: this.extraLine.length < 12, canRemove: this.extraLine.length > 0 }) setTimeout(() => { this.setData({ scrollTop: 99999 }) }, 0) }, remove() { if (this.extraLine.length > 0) { this.extraLine.pop() this.setData({ text: this.extraLine.join('\n'), canAdd: this.extraLine.length < 12, canRemove: this.extraLine.length > 0, }) } setTimeout(() => { this.setData({ scrollTop: 99999 }) }, 0) }})
{ { text}}
转载地址:https://codeboy.blog.csdn.net/article/details/107685872 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
很好
[***.229.124.182]2024年04月09日 10时09分13秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
插件机制+自定义axios(五)
2019-04-29
Redis的学习之路
2019-04-29
Windows下Redies+GUI安装,使用Jedis与spring boot 整合
2019-04-29
Windows创建本地版本库(1)
2019-04-29
基于java的酒店管理系统的设计与实现
2019-04-29
基于WEB的仓库管理系统的设计与实现
2019-04-29
基于java的web聊天系统
2019-04-29
基于java的俄罗斯方块的设计与实现
2019-04-29
基于java的魂斗罗的设计
2019-04-29
基于java的网页内容管理
2019-04-29
基于java的学生管理系统
2019-04-29
基于java网盘搜索的设计与实现
2019-04-29
基于SSM的仿小米商城源码
2019-04-29
基于SSM的医院人事管理系统的设计与实现
2019-04-29
基于SSM的网上购物系统的设计与开发
2019-04-29
基于SSM框架的BS微博系统的设计与实现
2019-04-29
超市订单管理系统
2019-04-29
基于ssm的民宿网站
2019-04-29
基于JavaWeb的物流管理系统的设计与实现
2019-04-29