这个例子是我仿照github上的一个例子后修改成的简单版,少了部分功能,初入门的我就简化来练手,不喜勿喷哦
这是原项目的地址:https://github.com/bailicangdu/vue2-happyfri
这是我修改后的项目地址:https://github.com/cenmen/vue-demo
开局先上效果图:开始页面-答题页面(五题)-结算得分;
项目目录如下:
首先是Background.vue组件,我只用了一个组件,其实应该要分组件的,但为了简单......
<template>
<div class="mainbody">
<div v-if="fatherComponent == 'home'" >
<div class="item_list_container">
<div class="home_logo_style"></div>
<span class="start_item button_style" @click="startAnswer"></span>
</div>
</div>
<div v-if="fatherComponent == 'answer'" >
<div class="item_list_container" v-if="itemDetail.length > 0">
<span class="num_tip">{
{itemDetail[itemNum-1].topic_num}}</span>
<span class="name_tip">{
{itemDetail[itemNum-1].topic_name}}</span>
<ul>
<li v-for="(item, index) in itemDetail[itemNum-1].topic_answer" @click="choosed(index, item.topic_answer_id)" class="item_list">
<span class="option_detail" v-bind:class="{'has_choosed':choosedNum==index}">{
{item.answer_name}}</span>
</li>
</ul>
<span class="next_item button_style" @click="nextItem" v-if="itemNum < itemDetail.length"></span>
<span class