fix: 解决预览异常的问题
This commit is contained in:
@@ -4,6 +4,8 @@ import { AnswerApi } from '@/views/Survey/views/Preview/js/api';
|
||||
import { getLanguage } from '@/views/Survey/views/Preview/js/language';
|
||||
|
||||
export const useQuestionStore = defineStore('questionStore', () => {
|
||||
const currentSn =ref<string>('');
|
||||
|
||||
const questionsData = ref();
|
||||
|
||||
// 是否是模板模式
|
||||
@@ -66,10 +68,12 @@ export const useQuestionStore = defineStore('questionStore', () => {
|
||||
// console.log(`l value:`, l.value);
|
||||
data.language = l.value;
|
||||
questionsData.value = data;
|
||||
|
||||
currentSn.value = urlParamSearch.get('sn') || '';
|
||||
}
|
||||
|
||||
return {
|
||||
fetchQuestions:getQuestions,
|
||||
currentSn,
|
||||
questionsData,
|
||||
styleInfo,
|
||||
page,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- <layout />-->
|
||||
<div ref="scrollbar" class="preview-container">
|
||||
<div ref="scrollbar" class="preview-container" v-memo="[currentSn]">
|
||||
<!-- <van-nav-bar :title="getDomString(questionsData?.survey?.title)" left-arrow />-->
|
||||
|
||||
<!-- 进度条 -->
|
||||
@@ -555,6 +555,7 @@ const questionStore = useQuestionStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const {
|
||||
currentSn,
|
||||
questionsData,
|
||||
styleInfo,
|
||||
page,
|
||||
@@ -588,6 +589,10 @@ const props = defineProps({
|
||||
|
||||
// 初始化 isTemplate
|
||||
isTemplate.value = props.isTemplate ? props.isTemplate : route.query.is_template === '1';
|
||||
// 如果当前的 sn 和 之前记录的sn不相同的时候,那么就要重新请求数据
|
||||
if (currentSn.value !== route.query.sn) {
|
||||
questionStore.fetchQuestions();
|
||||
}
|
||||
|
||||
// 上一页
|
||||
async function previous() {
|
||||
|
||||
Reference in New Issue
Block a user