Explorar o código

解决前进后退遇到的问题

Bay %!s(int64=6) %!d(string=hai) anos
pai
achega
02bb8495bb
Modificáronse 2 ficheiros con 6 adicións e 5 borrados
  1. 4 3
      src/App.vue
  2. 2 2
      src/views/JVVM.vue

+ 4 - 3
src/App.vue

@@ -67,20 +67,21 @@ export default {
       if (dataList && dataList.length > 0) {
         this.currentState = dataList[0]
       }
-      this.states = states
+      this.states = dataList
     })
   },
   methods: {
     handleNextFrame() {
+      console.log(this.states)
       if (this.currentStateIndex < this.states.length - 1) {
         this.currentState = this.states[this.currentStateIndex + 1]
-        this.currentStateIndex++
+        this.currentStateIndex += 1
       }
     },
     handlePreFrame() {
       if (this.currentStateIndex > 0) {
         this.currentState = this.states[this.currentStateIndex - 1]
-        this.currentStateIndex--
+        this.currentStateIndex -= 1
       }
     }
   }

+ 2 - 2
src/views/JVVM.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="jvvm">
     <source-code class="source-code"></source-code>
-    <j-v-m-code class="j-v-m-code" :code="state.currentFrame.code"></j-v-m-code>
+    <j-v-m-code v-if="state.currentFrame" class="j-v-m-code" :code="state.currentFrame.code"></j-v-m-code>
     <j-frame class="current-frame" name="current frame" :frame="state.currentFrame"></j-frame>
     <j-frame class="optional-frame" name="optional frame" :frame="state.optionalNextFrame"></j-frame>
     <memory v-if="state.memory" class="memory">
@@ -36,7 +36,7 @@ export default {
   },
   props: {
     state: {
-      default: () => ({ currentFrame: {}, optionalNextFrame: {}, memory: { objects: [] } }),
+      default: () => ({ currentFrame: { code: [] }, optionalNextFrame: {}, memory: { objects: [] } }),
       type: Object
     },
     currentStateIndex: {