【发布时间】:2017-08-27 14:03:22
【问题描述】:
所以在我的 nuxt.js 项目中,我需要一个自定义路由,如此处所述https://nuxtjs.org/examples/custom-routes
到目前为止,我已经实现了以下内容。
文件:pages\trails.vue
...
<nuxt-link v-bind:to="'/trail/' + trail.article_code">{{ trail.article_description }}</nuxt-link>
...
这相当于 index.vue 文件。如果我是正确的,则此文件中没有其他相关代码
文件:pages\trail\_id
<template>
<div class="vttTrails">
<div class="ui grid centered">
<div v-for="(trail, index) in listTrail">
<div class="ui card">
{{ trail.article_code }}
</div>
</div>
</div>
</div>
</template>
<script>
import feathers from 'feathers/client';
import socketio from 'feathers-socketio/client';
import hooks from 'feathers-hooks';
import io from 'socket.io-client';
import * as process from "../../nuxt.config";
const vttSocket = io(process.env.backendUrl);
const vttFeathers = feathers()
.configure(socketio(vttSocket))
.configure(hooks());
const serviceArticles = vttFeathers.service('articles');
export default {
layout: 'default',
data: function() {
return {
listTrail: [],
curLanguage: this.$store.state.site.curLanguage,
curCategory: this.$store.state.site.curCategory
}
},
mounted: function() {
return serviceArticles.find({
query: {
category_id: this.$store.state.site.curCategory,
article_code: '',
$sort: {
article_rating: 1
},
$select: [
'id',
['article_description_' + this.$store.state.site.curLanguage, 'article_description'],
'article_length',
'article_ascend',
'article_code',
'article_at',
]
}
}).then(page => {
this.listTrail = page.data;
})
},
}
</script>
所以我把整个文件放在这里,以防万一。单击链接将转到例如"trail\cwu" 这是正确的,因为我有。值“cwu”需要进入article_code: ''。我尝试做mounted: function(params),但它不起作用。
问题
我需要做什么才能在我的“_id.vue”中获取“params”部分?最终我会调整选择,因为它只会返回一个。
【问题讨论】:
标签: nuxt.js