原声html中怎么加载vue文件,HTML文件引入Vue开发

HTML文件引入Vue开发

页面标题

{{text}}

1290692835888144384.htm

{{item.text}}

1290692835888144384.htm

点击事件 @click

{{text}}

添加文本使用两个大括号{{文本}}

img标签中src前面得加冒号

1290692835888144384.htm

new Vue({

el: "#Vue",

data: {

text: "hallo,word",

img: "",

arr: []

},

methods: {

click() {

console.log(1111)

}

},

created() {

let that = this

$.ajax({

type: "get",//请求方式

async: false,

url: "__CONTROLLER__/gettesttos",

data: {},//传值给后台

dataType: "json",

success: function (res) {

console.log(res.info.data)

that.text = res.info.text

that.img = res.info.img

that.arr = res.info.data

},

});

}

})

data中定义需要使用的数据

data: {

text: "hallo,word",

img: "",

arr: []

},

在methods中写入点击事件

methods: {

click() {

console.log(1111)

}

},

请求接口后进行渲染

created() {

let that = this //定义一个that

$.ajax({

type: "get",//请求方式

async: false,

url: "__CONTROLLER__/gettesttos",

data: {},//传值给后台

dataType: "json",

success: function (res) {

console.log(res.info.data)

that.text = res.info.text

that.img = res.info.img

that.arr = res.info.data

},

});

}

for循环渲染要用v-for

item是自己定义的值

{{item.text}}

1290692835888144384.htm

arr是需要循环的数组名字

ff93db6ce301febe1d6e82694de87e70.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值