当前位置: 首页 > news >正文

直接打域名访问网站中装建设集团有限公司

直接打域名访问网站,中装建设集团有限公司,赣州网站建设中心,网上购物哪个商城好H5 中 van-popup 的使用以及题目的切换 在移动端开发中#xff0c;弹窗组件是一个常见的需求。vant 是一个轻量、可靠的移动端 Vue 组件库#xff0c;其中的 van-popup 组件可以方便地实现弹窗效果。本文将介绍如何使用 van-popup 实现题目详情的弹窗展示#xff0c;并实现…H5 中 van-popup 的使用以及题目的切换 在移动端开发中弹窗组件是一个常见的需求。vant 是一个轻量、可靠的移动端 Vue 组件库其中的 van-popup 组件可以方便地实现弹窗效果。本文将介绍如何使用 van-popup 实现题目详情的弹窗展示并实现题目的切换功能。 关键点总结 引入 van-popup 组件 在 Vue 项目中引入 vant 组件库并使用 van-popup 组件实现弹窗效果。 import { createApp } from vue import Vant from vantconst app createApp(App) app.use(Vant) app.mount(#app) 弹窗内容的条件渲染 根据不同的题目类型如互动题和练习题在弹窗中显示不同的内容。 题目详情的展示 使用 computed 属性计算当前题目的详情并在弹窗中展示题目的相关信息。 题目的切换 通过按钮实现题目的上一题和下一题的切换并更新当前题目的索引。 代码示例 以下是实现上述功能的关键代码片段 questions.vue---子组件 templatevan-popup v-model:showlocalVisible positionbottom round :style{ height: 80% } closeclosediv v-iftype interactivediv classpicker-headerdiv classpicker-title题目详情button clickclose classclose-buttonX/button/divdiv classpicker-infodiv classleft-infospan classnumber第{{ currentQuestion.serial_number }}题/spanspan classstatus{{ getStatusText(currentQuestion.status) }}/span/divdiv classright-infobutton v-if!isFirstQuestion clickprevQuestionvan-icon namearrow-left //buttonspan{{ currentQuestion.serial_number }}/{{ questions.length }}/spanbutton v-if!isLastQuestion clicknextQuestionvan-icon namearrow //button/div/div/divdiv classpicker-contentdiv classsection-title课件页面/diviframe :srccurrentQuestion.previewUrl frameborder0/iframediv classuse-duration我的用时span classtime-number{{ formattedDuration.minutes }}/span分 span classtime-number{{formattedDuration.seconds }}/span秒/div/div/divdiv v-else-iftype practice// 其他内容/div/van-popup /templatescript setup import { defineProps, defineEmits, computed, ref, watch } from vue import { Popup } from vantconst props defineProps({visible: Boolean,questions: {type: Array,required: true,},currentQuestionIndex: {type: Number,required: true,},type: {type: String,required: true,}, })const emits defineEmits([close, changeQuestion])const localVisible ref(props.visible)watch(() props.visible,newVal {localVisible.value newVal}, )const currentQuestion computed(() {const question props.questions[props.currentQuestionIndex] || {}if (props.type practice !question.serial_number) {question.serial_number props.currentQuestionIndex 1}return question })const getStatusText status {switch (status) {case 1:return 正确case 2:return 错误case 3:return 半对半错default:return 未作答} }const formatDuration duration {const minutes String(Math.floor(duration / 60)).padStart(2, 0)const seconds String(duration % 60).padStart(2, 0)return { minutes, seconds } }const formattedDuration computed(() formatDuration(currentQuestion.value.use_duration))const isFirstQuestion computed(() props.currentQuestionIndex 0) const isLastQuestion computed(() props.currentQuestionIndex props.questions.length - 1)const prevQuestion () {if (!isFirstQuestion.value) {emits(changeQuestion, props.currentQuestionIndex - 1)} }const nextQuestion () {if (!isLastQuestion.value) {emits(changeQuestion, props.currentQuestionIndex 1)} }const close () {emits(close) } /scriptstyle langless scoped .picker-header {padding: 10px; }.picker-title {font-size: 18px;font-weight: bold;justify-content: space-between;align-items: center;margin-bottom: 10px;color: #000;margin-top: 10px;display: flex;width: 100%;.close-button {background: none;border: none;font-size: 16px;margin-left: auto;color: #a9aeb8;cursor: pointer;} }.picker-info {display: flex;justify-content: space-between;align-items: center;padding: 0 10px 0 10px; }.left-info {display: flex;flex-direction: row;.number {margin-right: 20px;font-size: 16px;font-weight: 500;}.status {font-size: 16px;font-weight: 500;color: #1f70ff;} }.right-info {display: flex;position: absolute;right: 10px;color: #a9aeb8;.right-icon {width: 28px;height: 28px;} }.right-info button {background: none;border: none;font-size: 16px;cursor: pointer;margin: 0 5px; }.picker-content {padding: 10px 20px 0 20px; }.section-title {font-size: 16px;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;color: #2b2f38; }iframe {width: 100%;height: 300px;border: none;margin-bottom: 10px; }.use-duration {font-size: 16px;color: #2b2f38; }.time-number {font-weight: bold;color: #0074fc;font-size: 24px; }.van-popup {height: 50%;z-index: 99999; }.practice-content {padding: 0px 20px 0 20px; } /stylecourseDetail.vue---父组件 // template关键代码 div v-for(item, index) in period.interactive_performance.list :keyindex :class[performance-item,getStatusClass(item.status),{ selected: selectedQuestion index },] clickselectQuestion(index, period.interactive_performance.list, interactive)span :classgetQuestionTextClass(item.status, selectedQuestion index){{item.serial_number}}/span/divdiv v-for(item, index) in period.practice_detail.list :keyindex :class[practice-item,getStatusClass(item.status),{ selected: selectedPracticeQuestion index },] clickselectPracticeQuestion(index, period.practice_detail.list, practice)div classquestion-numberspan{{ index 1 }}/span/div /divQuestionDetail :visibleshowQuestionDetail :questionscurrentQuestions :typecurrentType:currentQuestionIndexcurrentQuestionIndex closecloseQuestionDetail changeQuestionchangeQuestion /// script关键代码 const selectQuestion (index, questions, type) {selectedQuestion.value indexcurrentQuestions.value questionscurrentType.value typecurrentQuestionIndex.value indexshowQuestionDetail.value true }const selectPracticeQuestion (index, questions, type) {selectedPracticeQuestion.value indexcurrentQuestions.value questionscurrentQuestionIndex.value index// 设置 serial_number 属性currentQuestions.value.forEach((question, idx) {question.serial_number idx 1})currentType.value typeshowQuestionDetail.value true } const changeQuestion index {currentQuestionIndex.value index } 数据结构 关键点解析 引入 van-popup 组件 在模板中使用 van-popup 标签并通过 v-model:show 绑定弹窗的显示状态。设置 positionbottom 和 round 属性使弹窗从底部弹出并带有圆角。 弹窗内容的条件渲染 使用 v-if 和 v-else-if 根据 type 属性的值渲染不同的内容。当 type 为 interactive 时显示互动题的详情当 type 为 practice 时显示练习题的详情。 题目详情的展示 使用 computed 属性计算当前题目的详情并在弹窗中展示题目的相关信息。通过 currentQuestion 计算属性获取当前题目的详细信息。 题目的切换 通过按钮实现题目的上一题和下一题的切换并更新当前题目的索引。使用 isFirstQuestion 和 isLastQuestion 计算属性判断当前题目是否为第一题或最后一题以控制按钮的显示和隐藏。 大致效果 通过以上关键点的实现我们可以在移动端应用中使用 van-popup 组件实现题目详情的弹窗展示并实现题目的切换功能。希望本文对您有所帮助
http://www.hkea.cn/news/14448662/

相关文章:

  • 网页制作培训要多少钱seo入门版
  • 网络营销讲师多网站怎么做seo
  • 医疗网站建设讯息开发网站需要多少资金
  • 网站建设方案计划书win7主机做网站
  • 做网站所需的知识技能湖南关键词优化品牌价格
  • 手机上有那种网站吗开发工具在哪里 word
  • 网站建设流程规划博罗做网站哪家强
  • 中国画廊企业网站模板廊坊建筑模板厂家电话
  • 怎么判断一个网站做的好wordpress5安装
  • 手机做照片下载网站对php网站开发技术课程总结
  • 设计师都上什么网站免费咨询期
  • 网站改版申请网页设计师资格证
  • 做行业网站广告如何在个人网上建网站
  • 视频建设网站首页公司ppt模板
  • 个人网站备案可以做公司网站用购物网站开发设计思路
  • 网站 建设阶段网站建设文化效果
  • 怎么设置iis默认网站在农村做相亲网站怎么样
  • 免费建立网站的平台规范门户网站的建设和管理办法
  • 潍坊网站建设熊掌号互联网+营销策略怎么写
  • 上海知名网站开发公司怎么做网页链接教程
  • 西安做网站印象网络湖北住房与城乡建设厅网站
  • 策划设计网站中国空间站科幻作文1000字
  • 网站规划与建设重要性理解与体会forum wordpress
  • 三网合一网站远吗wordpress alchem
  • 做八闽最好的中学网站秦皇岛平台公司
  • 自适应网站主要用什么做网站sem优化怎么做
  • 昌网站建设网站建设厦门
  • 网站做服装那个平台好一点中国电力建设集团公司官方网站
  • 房产信息网网站linux系统打开wordpress
  • 深圳 网站建设 公司网站建设在线推广