what should I do when I send back the requested data in a different style?
the red box is marked by two pieces of data
I have tried several ways, please give me some advice
what should I do when I send back the requested data in a different style?
the red box is marked by two pieces of data
I have tried several ways, please give me some advice
emmmm
use two styles from left to right. When looping, I% 2 = 0
use class
according to parity
according to the requirements, you can add different classes according to the parity of the data, or you can add a variety of different classes according to the attributes of the data
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdn.bootcss.com/vue/2.5.13/vue.js"></script>
<title>Document</title>
<style>
li.odd{
background-color: -sharpaaa;
}
li.even{
background-color: coral;
}
</style>
</head>
<body>
<div id="app">
<ul>
<li v-for="(v,k) in lists" :key="k" :class="addDifClass(k)">
<div>{{v.time}}</div>
<h2>{{v.title}}</h2>
<div>{{v.content}}</div>
</li>
</ul>
</div>
<script async>
var app = new Vue({
el: '-sharpapp',
data: {
message: 'Hello Vue!',
lists:[],
},
methods: {
//
// v vclass
addDifClass(k){
if(k%2==0){
return {even:true}
}else{
return {odd:true}
}
}
},
created() {
//
const mockdata = [
{ time: '2018-5', title: 'title', content: 'content111' },
{ time: '2018-6', title: 'title2', content: 'content111' },
{ time: '2018-6', title: 'title2', content: 'content111' },
{ time: '2018-6', title: 'title2', content: 'content111' },
{ time: '2018-6', title: 'title2', content: 'content111' },
]
this.lists=mockdata;
}
})
</script>
</body>
</html>
I hope I can help you. If there is any help, I hope to adopt
.this is very basic, concatenate strings and render different strings according to the index during the loop.
</b>
</li>
this is very clear. The content can be changed, and it doesn't have to be written to death like 1p2, and the content can all be changed
.Previous: For in problem in javascipt
Next: How to understand that attributes of the same name will not appear in Symbol?
for example: < tr vmurfort = "item in Data " > <td class="red">{{item.td}}< td> < tr > Data = [td:12,td:14] what if I want to add a separate red style for td > 13? ...
there is a list page as shown below: " " 1011: " " : vue ...
question background: there is a wireless drop-down list on page A, click on a list item and jump to the new page B; during the return of page B to A, the keep-alive operation is performed on page A, that is, the page is cached, the data of page An is ...
the front-end asynchronous API acquires data as follows, and the whole string is a large one: "-sharp-sharp 2018.05.08Version: 1.0.65-sharp-sharp-sharp New Features- [Navs](http: a.com):Navs [Tabs](http: a.com):-TabsiScroll - [Tags](http: a.com...
problem description export default { functional: true, props: { data: { type: String, default() { return ; } }, depth: { type: Number } }, ...
in the requirements of the project, vue-for is used to load the data and display it in tr, but the data is required to be displayed in two rows. My solution is as follows: <table> <thead>< thead> <tr v-for="...
No problem on ios. Sliding up and down is basically no problem. Android pull-down refresh conflicts with the sliding area in the middle of the page, and once you swipe up (that is, when the finger is pulled down), it triggers the entire page drop-down ...
< div id=box > <img src= > < div > < H1 > box {< H1 > overflow: hidden height: 0 padding-bottom: 43.372rem } at present, the width and height of 1rem = 50px pictures are 640276 respectively. How is the value of the aspect ratio padding-...
https: caniuse.com -sharpsearch=p. at the bottom of the page, I also see a section saying that it supports ios ( https: caniuse.com -sharpfeat=poi. is not good at English, so what does it mean that pointer events is not compatible with ios in the...
effects on Android mobile devices: : attached code: data:{ iconMove:". images icon_move_right.png", } mounted:function () { var that=this; var right_div2 = document.getElementById("right_div2"...
watch: { $route (to, from) { this._findBread() this.lastRoutePath = from.path this.$nextTick(() => { autoHeight() container.style.minHeight = calc(100% - 30px) }) } }, <transition name="fade&quo...
I want to display locally acquired json data in this div in the same format (as in the figure), so I used pre, but I couldn t show it. But consloe.log can be output in the background. Solve <div class="mod-2"> <!-- json --> ...