上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<style></style>
</head>
<body>
<div id="box">
<div style="width: 450px;padding:20px;border: 1px solid red;margin:0 auto;">
<div v-for="item,index of dazu" :key="index">
<div style="color: red;">
<span>{{item.lufei}}</span>
<span>{{item.ll}}</span>
<span>{{item.shuo}}</span>
</div>
<div style="text-align: right;color: rgb(241, 12, 222);">
<span>{{item.shuo1}}</span>
<span>{{item.ss}}</span>
<span>{{item.suolong}}</span>
</div>
</div>
<input type="text" v-model="suoming">
<input type="text" v-model="suozhi">
<button @click="slbtn">索隆专用</button>
<button @click="lfbtn">路飞专用</button>
</div>
// 音乐播放暂停
<div>
<audio id="audio" ref="audioDom"
src="稻香.mp3"
controls="controls" loop="loop" autoplay="autoplay"></audio>
<button @click="handleClick">点击关闭</button>
<button @click="handleClicks">点击播放</button>
</div>
</div>
</body>
<script>
new Vue({
el:"#box",
data(){
return {
dazu:[
{lufei:'路飞',ll:':',shuo:'我是蒙奇D路飞',suolong:'索隆',ss:':',shuo1:'我是罗罗诺亚索隆'}
],
suoming:'',
suozhi:'',
}
},
methods:{
slbtn(){
this.dazu.push({
suolong:this.suoming,
ss:':',
shuo1:this.suozhi
})
},
lfbtn(){
this.dazu.push({
lufei:this.suoming,
ll:':',
shuo:this.suozhi
})
},
handleClick: function () {
this.$refs["audioDom"].pause();
},
handleClicks: function () {
this.$refs["audioDom"].play();
}
}
})
</script>
</html>