1. 使用v-text指令,将数据采用纯文本方式填充其空元素中
import { reactive } from 'vue' let student = reactive({ name: 'Jack', desc: '我是来自中国的小朋友!
' }) <template> <div v-text="student.name">div> <div v-text="student.desc">div> template>2.
{{ }}插值表达式:在元素中的某一位置采用纯文本的方式渲染数据
这是一个 DIV 元素,{{ student.name }},{{ student.desc }}3. 使用v-html指令,将数据采用HTML语法填充其空元素中
import { reactive } from 'vue' let student = reactive({ name: 'Jack', desc: '我是来自中国的小朋友!
' }) <template> <div v-html="student.name">div> <div v-html="student.desc">div> template>
v-model双向数据绑定指令,视图数据和数据源同步,一般情况下v-model指令用在表单元素中:
1. 文本类型的和v-model的修饰符
- import { reactive } from 'vue'
- let picture = reactive({
- src: 'https://uploadfile.bizhizu.cn/2015/0424/20150424015229741.jpg', // 图像地址
- width: 200 // 显示宽度
- })
-
-
-
-
![]()
-
-
-
![]()
-
-
-
- import {reactive} from 'vue'
- let attrs = reactive({
- class: 'error',
- id: 'borderBlue'
- })
- <template>
-
- <button v-bind="attrs">我是一个普通的按钮button>
- template>
- <style>
- .error {
- background-color: rgb(167, 58, 58);
- color: white;
- }
-
- #borderBlue {
- border: 2px solid rgb(44, 67, 167);
- }
- style>