반응형
this.$refs, this.$140, 이거요.Vue 2 Composition API를 사용한 $route 액세스
접속 방법을 알려주시겠습니까?this.$refs
,this.$router
,this.$route
Vue 2 Composition API 셋업 기능에 포함됩니까?에는 다음과 같은 솔루션이 있습니다.context.$root
그렇지만$root
에서는 사용할 수 없습니다.context
더이상.제발 도와주세요.
컴포지션 API 플러그인과 함께 Vue 2를 사용하고 있습니다.그런 것 같다useRoute
또는useRouters
는 Vue 2 라우터 버전을 지원하지 않습니다. useRoute
그리고.useRouters
는 Vue-router v4에서 사용할 수 있습니다.
모듈에서 라우터를 Import하여 두 개의 라우터에 모두 액세스 할 수 있습니다.router
그리고.route
그것으로부터.
참조는 Vue 3과 동일한 방법으로 사용할 수 있습니다.
import { ref, onMounted } from "@vue/composition-api"; // import ref, onMounted
import router from "@/router"; // import router
export default {
setup() {
console.log(router); // this.$router
console.log(router.app.$route); // this.$route
const myref = ref(null); // create ref
onMounted(() => {
console.log(myref); // this.$refs.myref
});
return { myref }; // return for template ref
},
};
언급URL : https://stackoverflow.com/questions/66469544/this-refs-this-router-this-route-access-with-vue-2-composition-api
반응형
'programing' 카테고리의 다른 글
Nuxt Js를 사용하여 스크립트 태그에 데이터 속성을 추가하는 방법 (0) | 2022.08.01 |
---|---|
nuxt.js 미들웨어에서 vuex 스토어 getter를 사용할 수 없습니다. (0) | 2022.08.01 |
제출 시 폼 데이터를 가져오고 있습니까? (0) | 2022.08.01 |
(A+B)의 FFT가 FFT(A) + FFT(B)와 다른 이유는 무엇입니까? (0) | 2022.08.01 |
v-select에 사용자 지정 텍스트 입력 (0) | 2022.08.01 |