<text>
是 Weex 内置的组件,用来将文本按照指定的样式渲染出来.
注意:
<text>
里直接写文本头尾空白会被过滤,如果需要保留头尾空白,暂时只能通过数据绑定写头尾空格。
注意:
<text>
不支持子组件。
除了动态文本,text组件不支持其他属性
下列代码片段可以实现文字内容和JS变量的绑定。
<template> <div> <text >{{content}}</text> </div> </template> <script> module.exports = { data: function(){ return { content: "Weex is an cross-platform development solution that builds high-performance, scalable native applications with a Web development experience. Vue is a lightweight and powerful progressive front-end framework. " } } } </script>
支持 通用事件。
文字高度的计算规则比较复杂,但大致上遵循以下优先级进行计算,排在前面的优先级最高。
max-height
/min-height
样式。flex
属性且文字的父节点上有flex-direction:column
样式。height
样式。align-items:stretch
如果文字父节点有 flex-direction:row
样式。支持版本:v0.12.0
支持ttf和woff字体格式的自定义字体, 可以通过调用 dom
module 里面的 addRule方法, 构建自定义的font-family
使用, addRule 建议在 beforeCreate
或者更早时调用