Skip to content

Text 文本

This component integrates the common functions of the text class in the project, including status, call number, deletion date, * replacement, hyperlink... and other functions. You don't have to define it yourself when using special text, the text component almost covers most of the scenarios you can use.

Platform compatibility

App(vue)App(nvue)H5小程序VUE2VUE3

basic use

Set the text content via the text parameter. It is recommended that you use :text='value'

vue
<wu-text text="大鹏一日同风起,扶摇直上九万里"></wu-text>
<wu-text text="大鹏一日同风起,扶摇直上九万里"></wu-text>

set theme

  • Set the text theme through the type parameter, we provide five types of attributes.
  • primary error success warning info
vue
<wu-text type="primary" text="main color"></wu-text>
<wu-text type="error"   text="mistake"></wu-text>
<wu-text type="success" text="success"></wu-text>
<wu-text type="warning" text="warn"></wu-text>
<wu-text type="info"    text="info"></wu-text>
<wu-text type="primary" text="main color"></wu-text>
<wu-text type="error"   text="mistake"></wu-text>
<wu-text type="success" text="success"></wu-text>
<wu-text type="warning" text="warn"></wu-text>
<wu-text type="info"    text="info"></wu-text>

dial number

  • By setting the mode attribute to phone, the phone call can be called, providing the encrypted value encrypt
  • In addition, there are attributes such as formatted date, name desensitization, hyperlink, and thousand percent amount, which will be shown in the following examples
vue
<wu-text mode="phone" text="17363987953"></wu-text>
<wu-text mode="phone" text="17363987953"></wu-text>

date formatting

vue
<wu-text mode="date" text="1691825812"></wu-text>
<wu-text mode="date" text="1691825812"></wu-text>

name desensitization

vue
<wu-text mode="name" text="张三三" format="encrypt"></wu-text>
<wu-text mode="name" text="张三三" format="encrypt"></wu-text>

Add href to specify the link address

vue
<wu-text mode="link" text="Go to uView docs" href="https://wuui.cn"></wu-text>
<wu-text mode="link" text="Go to uView docs" href="https://wuui.cn"></wu-text>

show amount

vue
<wu-text mode="price" text="1723231.77"></wu-text>
<wu-text mode="price" text="1723231.77"></wu-text>

beyond hidden

The built-in text exceeds the hidden style, set the lines property to indicate that it will be hidden after a few lines

vue
<wu-text  :lines="2" text="The origin of the name of wu-ui comes from a joke. I once told a few good friends that we should set up an organization called Wolongfengchu. The initial letter w comes from the initial letter of Wo, and u comes from Because of uniapp, it is named wu-ui, and the expression comes from uni-app and uView, and I would also like to express my gratitude to them."></wu-text>
<wu-text  :lines="2" text="The origin of the name of wu-ui comes from a joke. I once told a few good friends that we should set up an organization called Wolongfengchu. The initial letter w comes from the initial letter of Wo, and u comes from Because of uniapp, it is named wu-ui, and the expression comes from uni-app and uView, and I would also like to express my gratitude to them."></wu-text>

Small program open ability

For the opening capability of the Mini Program, we provide sharing, please use it in the Mini Program environment

vue
<wu-text text="Share to WeChat" openType="share" type="success" @click="clickHandler"></wu-text>
<script>
	export default {
		onLoad() {},
		methods: {
			clickHandler() {
				// #ifndef MP-WEIXIN
				this.$w.toast('Please check the effect in the WeChat applet')
				// #endif
			}
		},
	}
</script>
<wu-text text="Share to WeChat" openType="share" type="success" @click="clickHandler"></wu-text>
<script>
	export default {
		onLoad() {},
		methods: {
			clickHandler() {
				// #ifndef MP-WEIXIN
				this.$w.toast('Please check the effect in the WeChat applet')
				// #endif
			}
		},
	}
</script>

API

Text Props

Attribute NameillustratetypesDefault valueOptional values ​​
typetheme colorString--
showwhether to displayBooleantruetrue / false
textdisplayed valueString / Number--
prefixIconprefix iconString--
suffixIconsuffix iconString--
modeMatching mode for text processing, text-normal text, price-price, phone-mobile phone number, name-name, date-date, link-hyperlinkString--
hrefmode=link, the configured linkString--
formatformatting rulesString / Function--
callWhen mode=phone, click the text whether to call or notBooleanfalsetrue / false
openTypeThe way to open the appletString--
boldbold or not, default normalBooleanfalsetrue / false
blockblock or notBooleanfalsetrue / false
linesThe number of lines displayed in the text, if set, an ellipsis will be displayed if it exceeds this numberString / Number--
colortext colorString--
sizefont sizeString / Number15-
iconStyleIcon styleObject / String15px-
decorationText decoration, underline, middle line, etc.Stringnoneunderline / line-through
marginMargin, object, string, numeric form can beObject / Number / String--
lineHeighttext line heightNumber / String--
aligntext alignmentStringleftleft / center / right
wordWrapword wrapStringnormalbreak-word / anywhere

Text Events

nameillustrateCallback Arguments
clickclick trigger event-