The weex builtin component ‘text’ is used to render text with specified style rule. tag can contain text value only. You can use variable interpolation in the text content with the mark {% raw %}{{}}{% endraw %}
.
This component supports no child components.
var textComponent = this.$el("textid"); this.text = textComponent.attr.value;
lines: specify the text lines. Default value is 0
for unlimited.
text styles: check out text styles
32
. Android: platform specify. HTML5: default value 32
.check out common styles for components
check out common events
support:v0.12.0
support ttf
and woff
font format to custom your text, call addRule in dom module to build your own font-family
, we suggest that you call addRule
in beforeCreate
<template> <div style='flex-direction:row;margin-top:50px'> <text style='font-family:iconfont4;font-size:50;color:green'></text> <text style='font-family:iconfont4;font-size:50;'></text> <text style='font-family:iconfont4;font-size:60;color:blue'></text> <text style='font-family:iconfont4;font-size:60;color:green'></text> </div> </template> <script> module.exports = { beforeCreate: function() { var domModule = weex.requireModule('dom'); //support ttf、woff file,svg、eot can not be supported ,moreItem at http://www.iconfont.cn/ domModule.addRule('fontFace', { 'fontFamily': "iconfont2", 'src': "url('http://at.alicdn.com/t/font_1469606063_76593.ttf')" }); } } </script>
<template> <div class="wrapper"> <div class="panel"> <text class="text" lines="3">Weex 是一套简单易用的跨平台开发方案,能以 Web 的开发体验构建高性能、可扩展的原生应用。Vue 是一个轻量并且功能强大的渐进式前端框架。</text> </div> <div class="panel"> <text class="text" lines="3">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. </text> </div> </div> </template> <style scoped> .wrapper { flex-direction: column; justify-content: center; } .panel { width: 600px; margin-left: 75px; border-width: 2px; border-style: solid; border-color: #BBB; padding-top: 15px; padding-bottom: 15px; padding-left: 15px; padding-right: 15px; margin-bottom: 30px; } .text { lines: 3; color: #666666; font-size: 32px; } </style>