export default {
data: () => ({
comments: [],
}),
methods: {
loadComments() {
this.comments = axios.get('...').then(response => response.data)
},
scrollToComment() {}
},
async mounted() {
await this.loadComments();
const commentId = this.$router.query.comment
// scrollToComment - ваша функция, которая скроллит до коммента
this.$nextTick(this.scrollToComment(commentId))
}
}
import Vue from 'vue';
import VueRouter from 'vue-router';
import Vuex from 'vuex';
import {routes} from './routes';
import MainApp from './components/MainApp.vue';
Vue.use(VueRouter);
Vue.use(Vuex);
Vue.component('main-app', MainApp);
const router = new VueRouter({
router,
mode: 'history'
});
const app = new Vue({
el: '#app',
router
});