<?php
/*
* Template Name: Thankyou page
*/
get_header();
if($_GET['order_id']){
$orderId = $_GET['order_id'];
}
?>
<div class="container">
<h1>Thank you. Your order has been received.</h1>
<h2>Order details:</h2>
<span>Order Number: <?php echo $orderId; ?> </span>
</div>
<?php get_footer(); ?>
我只想将perPage属性访问swiperOption对象
请帮助我
答案 0 :(得分:1)
您不能直接分配未声明的数据属性。相反,您可以在创建的挂钩中将perPage设置为swiperOption
只需添加创建的挂钩
data() {
return {
perPage:2,
swiperOption: {
slidesPerView: 0,
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
},
}
},
created() {
this.swiperOption.slidesPerView = this.perPage;
}
答案 1 :(得分:0)
我认为您不能在声明对象的同时访问对象的属性 ,但是由于data
是一个函数,您可以仅将perPage
分配给变量:>
data(){
var perPage = 2;
return {
perPage:perPage,
swiperOption: {
slidesPerView: perPage,
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
},
}
}
答案 2 :(得分:0)
perPage
是常数还是会随某些东西而改变?
如果它是常量,则无需在data()
内声明它。
但是,如果更改,一种方法是在其上设置观察者,并在每次更改时使用新值更新swiperOption。像这样:
watch(){
perPage(newVal){
this.swiperOption.slidesPerView = newVal;
}
}