Browse Source

修改布局 切换滚动

master
lillillli 3 years ago
parent
commit
b26e2e5e04
  1. 66
      src/views/home.vue

66
src/views/home.vue

@ -79,11 +79,14 @@
</p> </p>
</div> </div>
<div class="box_section box_5" v-focusable> <div class="box_section box_5" ref="box_section">
<div <div
class="information" class="information"
v-for="(item, index) in infoData" v-for="(item, index) in infoData"
:key="index" :key="index"
@onFocus="mationFocus(item.index, $event)"
@down="mationDown(item.index, $event)"
v-focusable
> >
<p <p
style=" style="
@ -160,6 +163,7 @@ export default {
data() { data() {
return { return {
active: 0, active: 0,
state: 0,
navData: [ navData: [
{ name: "首页", index: 0 }, { name: "首页", index: 0 },
{ name: "农民夜校", index: 1 }, { name: "农民夜校", index: 1 },
@ -171,14 +175,22 @@ export default {
], ],
infoData: [ infoData: [
{ {
index: 0,
info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...", info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...",
print: require("../assets/img/Rectangle2221.png"), print: require("../assets/img/Rectangle2221.png"),
}, },
{ {
index: 1,
info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...", info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...",
print: require("../assets/img/Rectangle2221.png"), print: require("../assets/img/Rectangle2221.png"),
}, },
{ {
index: 2,
info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...",
print: require("../assets/img/Rectangle2221.png"),
},
{
index: 3,
info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...", info: "近日,剑阁县龙源镇纪委联合镇疫情防控领导专班深入场镇干单位、村(社区)开展疫...",
print: require("../assets/img/Rectangle2221.png"), print: require("../assets/img/Rectangle2221.png"),
}, },
@ -195,7 +207,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.$tv.reset(); this.$tv.reset();
this.$tv.focusClassName = "box_focusable"; // class this.$tv.focusClassName = "box_focusable"; // class
// this.$tv.init({ distanceToCenter: true }); // // this.$tv.init({ distanceToCenter: true }); //
// this.$tv.setScrollEl(document.querySelector(".home_nav")); // div // this.$tv.setScrollEl(document.querySelector(".home_nav")); // div
// this.$tv.setScrollEl(this.$tv.getElementByPath('//div[@class="nav_li"]')); // div // this.$tv.setScrollEl(this.$tv.getElementByPath('//div[@class="nav_li"]')); // div
}); });
@ -227,7 +239,7 @@ export default {
} }
this.active = index; this.active = index;
this.$tv.requestFocus(document.querySelector(`.tab_nav_${index + 1}`)); this.$tv.requestFocus(document.querySelector(`.tab_nav_${index + 1}`));
// console.log(this.active); // console.log(this.active);
}, },
navLeft(index) { navLeft(index) {
@ -237,7 +249,7 @@ export default {
this.active = index; this.active = index;
this.$tv.requestFocus(document.querySelector(`.tab_nav_${index - 1}`)); this.$tv.requestFocus(document.querySelector(`.tab_nav_${index - 1}`));
} }
// console.log(event.target, "left"); // console.log(event.target, "left");
console.log(this.active); console.log(this.active);
}, },
@ -256,6 +268,24 @@ export default {
false false
); );
}, },
mationFocus(index) {
//menu
this.state = index;
this.$tv.setScrollEl(
this.$refs.box_section
// this.$tv.getElementByPath("//div[@class='box_section']")
);
},
mationDown(i, event) {
//menuitem
if (i == this.infoData.length) {
this.$tv.requestFocus(event.target);
}
console.log(event.target);
console.log("111");
},
}, },
}; };
</script> </script>
@ -286,7 +316,7 @@ p {
transform: scale(1.04); transform: scale(1.04);
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
border: solid #FFA564; border: solid #ffa564;
} }
// //
@ -320,10 +350,10 @@ ul {
color: #798190; color: #798190;
font-size: 18px; font-size: 18px;
display: flex; display: flex;
} li {
li { width: 148px;
width: 148px; text-align: center;
text-align: center; }
} }
.nav_li { .nav_li {
@ -339,12 +369,7 @@ li {
margin: 0; margin: 0;
height: 511px; height: 511px;
} }
.information {
display: flex;
align-items: center;
height: 67px;
margin-bottom: 16px;
}
.scenic { .scenic {
position: relative; position: relative;
width: 300px; width: 300px;
@ -380,10 +405,19 @@ li {
height: 221px; height: 221px;
box-sizing: border-box; box-sizing: border-box;
padding: 16px; padding: 16px;
overflow-y: hidden;
border-radius: 10px; border-radius: 10px;
background: linear-gradient(180deg, #163d7e 0%, #1d3256 100%); background: linear-gradient(180deg, #163d7e 0%, #1d3256 100%);
.information {
width: 100%;
height: 67px;
display: flex;
align-items: center;
margin-bottom: 16px;
box-sizing: border-box;
}
} }
figure { figure {
width: 118px; width: 118px;
height: 172px; height: 172px;

Loading…
Cancel
Save