Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

vue.js - Passing a const included in fucntion to component in another Tab in IONIC VUE JS

that's my first post. I have a problem with passing an Array from function included in Home.vue to component 'testField' at Result.vue

You can see a function which I want to pass below. showResult() is activated when I click this button:

<ion-button id="finalBtn" color="success" v-on:click="showResult" >Calc It!</ion-button>
//INTO Home.vue methods:{ }

// METHOD WHICH I WANT TO PASS 
showResult(){

const powerfulArray= new Array(2);
powerfulArray[0]=new Array(2);
/* DECLARATION ARRAY */

powerfulArray[0][0][0][0][0]=28;
/* INITIALIZING VALUES FOR FIELDS */

},

Home.vue :

import { IonContent, IonHeader, IonPage, IonRadio, IonTitle, IonToolbar,IonButton,IonInput,IonLabel,IonRadioGroup, alertController } from '@ionic/vue';
import { defineComponent } from 'vue';
  import { useRouter } from 'vue-router';
  // import { routeLocationKey } from 'vue-router';
  // import { inject } from 'vue';
export default defineComponent({
  name: 'Home',
  components: {
    IonContent,
    IonHeader,
    IonPage,
    IonTitle,
    IonToolbar,
    IonButton,
    IonInput,
    IonLabel,
    IonRadio,
    IonRadioGroup,
  },
  data(){
    return {
ageGRP:'',
sex:'',
smoking:'',
pressure:'',
cholesterol:'',
    }},

methods:{
setup() {
      const router = useRouter();
      return { router };
    },
}

Result.vue :

import { IonContent, IonHeader, IonPage,  IonTitle, IonToolbar,IonInput,IonLabel  } from '@ionic/vue';
import { defineComponent } from 'vue';
// import { useRoute } from 'vue-router';
 import showResult from './Home.vue';

export default defineComponent({
  name: 'Result',
  components: {
    IonContent,
    IonHeader,
    IonPage,
    IonTitle,
    IonToolbar,
    IonInput,
    IonLabel, 
  },
data(){
  return {
wartosc: 'TEST'
  }
},
methods:{
setup(){
  console.log(showResult.powerfulArray[0][0][0][0][0]);
},
}
});

Finally I want value of showResult.powerfulArray to but as you can see I can't use that even in this simply example.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...