vuejs2

vue: how to make the object passed to component reactive?

限于喜欢 提交于 2021-01-03 07:41:53
问题 Codepen Demo I have a component which has an location object as props . The argument I passed in is locations[index] which is a selected item from a locations array. However, the component cannot react when the index change. As you can see in the demo, the JSON change as you click the button, but the component cannot update. What's the best way to make the component reactive? 回答1: Your location component populates the province and city data properties in the mounted hook only. When the

vue: how to make the object passed to component reactive?

时光怂恿深爱的人放手 提交于 2021-01-03 07:41:48
问题 Codepen Demo I have a component which has an location object as props . The argument I passed in is locations[index] which is a selected item from a locations array. However, the component cannot react when the index change. As you can see in the demo, the JSON change as you click the button, but the component cannot update. What's the best way to make the component reactive? 回答1: Your location component populates the province and city data properties in the mounted hook only. When the

vue: how to make the object passed to component reactive?

眉间皱痕 提交于 2021-01-03 07:41:46
问题 Codepen Demo I have a component which has an location object as props . The argument I passed in is locations[index] which is a selected item from a locations array. However, the component cannot react when the index change. As you can see in the demo, the JSON change as you click the button, but the component cannot update. What's the best way to make the component reactive? 回答1: Your location component populates the province and city data properties in the mounted hook only. When the

get route params in asyncData after router push

两盒软妹~` 提交于 2021-01-03 06:57:55
问题 I'm trying to get the route params in the asyncData method, it works if I go manually to the route, but if I use router Push method, it doesn't get any params. this is my asynData method: async asyncData(ctx) { const { id } = ctx.app.router.currentRoute.params await ctx.store.dispatch('user/GET_USER', id) return { user: ctx.store.state.user.user } }, and this is how I navigate to the respective page: goToEdit(id) { this.$router.push({ path: `/users/${id}/edit` }) } 回答1: You need to get route

get route params in asyncData after router push

蓝咒 提交于 2021-01-03 06:57:42
问题 I'm trying to get the route params in the asyncData method, it works if I go manually to the route, but if I use router Push method, it doesn't get any params. this is my asynData method: async asyncData(ctx) { const { id } = ctx.app.router.currentRoute.params await ctx.store.dispatch('user/GET_USER', id) return { user: ctx.store.state.user.user } }, and this is how I navigate to the respective page: goToEdit(id) { this.$router.push({ path: `/users/${id}/edit` }) } 回答1: You need to get route

get route params in asyncData after router push

断了今生、忘了曾经 提交于 2021-01-03 06:57:29
问题 I'm trying to get the route params in the asyncData method, it works if I go manually to the route, but if I use router Push method, it doesn't get any params. this is my asynData method: async asyncData(ctx) { const { id } = ctx.app.router.currentRoute.params await ctx.store.dispatch('user/GET_USER', id) return { user: ctx.store.state.user.user } }, and this is how I navigate to the respective page: goToEdit(id) { this.$router.push({ path: `/users/${id}/edit` }) } 回答1: You need to get route

How to add Jitsi Meet to Vuejs

自古美人都是妖i 提交于 2021-01-03 06:17:32
问题 I have loaded the jitsi meet script in the body of my public.html, and i have a component as follows: <template> <div class="container"> <div id="meet"></div> </div> </template> <script> export default { name: "ServiceMeet", mounted() { const domain = "meet.jit.si"; const options = { roomName: "PickAnAppropriateMeetingNameHere", width: 700, height: 700, parentNode: document.querySelector("#meet"), }; const api = new JitsiMeetExternalAPI(domain, options); console.log(api.getVideoQuality()); },

How to add Jitsi Meet to Vuejs

蹲街弑〆低调 提交于 2021-01-03 06:17:05
问题 I have loaded the jitsi meet script in the body of my public.html, and i have a component as follows: <template> <div class="container"> <div id="meet"></div> </div> </template> <script> export default { name: "ServiceMeet", mounted() { const domain = "meet.jit.si"; const options = { roomName: "PickAnAppropriateMeetingNameHere", width: 700, height: 700, parentNode: document.querySelector("#meet"), }; const api = new JitsiMeetExternalAPI(domain, options); console.log(api.getVideoQuality()); },

How listen to all events from one component in VueJS?

半世苍凉 提交于 2020-12-29 22:50:50
问题 Is there a possibility in Vue to deal with incoming events inside one function in a way similar to this? <template> <component v-on="eventsDistributor(eventName, $event)"/> </template> <script> export default { props: { handlers: Object, }, methods : { eventsDistributor (name, $event) { let handler = this.handlers[name] if (handler) return handler($event) } } } </script> 回答1: I think $listeners might be what you need. It's an object that contains all parent listeners, and it could be

Call method from component inside component's <slot></slot>

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-29 13:14:49
问题 I'm learning Vue.js and I'm struggling to find a way to organize my code. I'm trying to make everything as modular as possible, so when making a slider i did the following: <template> <div class="banners"> <slot></slot> </div> </template> <script> export default { methods: { echo() { console.log('Echoing..') } }, mounted() { $('.banners').slick(); } } </script> And in my view I simply use the component: <banners> <?php for ($i = 0; $i < 5; $i++) : ?> <img src="http://lorempixel.com/1440/500"