<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
<div v-for="item in list">
<div v-if="item.status === 2">
<span>{{getTopInfo(item)}}</span>
<span @click="ent()" style="color: blue">{{item.title}}</span>
<span>{{getAfterInfo(item)}}</span>
</div>
<div v-else @click="ent()" style="color: blue">{{item.text}}</div>
</div>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
new Vue({
el: '#app',
data: function () {
return {
list: [
{
status: 1,
text: '标题1'
},
{
status: 2,
title: '标题2',
text: '11111,标题2,2132131321',
},
{
status: 3,
text: '标题3',
},
],
}
},
methods: {
getTopInfo(row) {
return row.text.substring(0, row.text.indexOf(row.title))
},
getAfterInfo(row) {
return row.text.substring(row.text.indexOf(row.title) + row.title.length , row.text.length)
},
ent() {
console.log(1)
}
},
})
</script>
</html>
02-24
163