mirror of
https://gitee.com/novel_dev_team/novel-front-web
synced 2026-07-20 17:54:10 +08:00
feat: 增加新闻页
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
type="text"
|
||||
placeholder="书名、作者、关键字"
|
||||
class="s_int"
|
||||
v-on:keyup.enter="searchByK"
|
||||
/>
|
||||
<label class="search_btn" id="btnSearch" @click="searchByK()"
|
||||
><i class="icon"></i
|
||||
|
||||
@@ -2,24 +2,25 @@
|
||||
<dl class="hot_notice" id="indexNews">
|
||||
<dd style="text-align: left" v-for="(item, index) in newsList" :key="index">
|
||||
<span>[{{ item.categoryName }}]</span>
|
||||
<router-link :to="{ name: 'newsContent', query: { id: item.id } }">
|
||||
{{ item.title }}
|
||||
</router-link>
|
||||
<a href="javascript:void(0)" @click="newsInfo(item.id)"> {{ item.title }}</a>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { reactive, toRefs, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { ElMessage, ElLoading } from "element-plus";
|
||||
import {listLatestNews} from "@/api/news";
|
||||
import { listLatestNews } from "@/api/news";
|
||||
export default {
|
||||
name: "LatestNews",
|
||||
setup() {
|
||||
const state = reactive({
|
||||
newsList: [],
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
onMounted(async () => {
|
||||
const loadingInstance = ElLoading.service({
|
||||
target: "#indexNews",
|
||||
@@ -30,9 +31,12 @@ export default {
|
||||
|
||||
state.newsList = data;
|
||||
});
|
||||
|
||||
const newsInfo = (newsId) => {
|
||||
router.push({ path: `/news/${newsId}` });
|
||||
};
|
||||
return {
|
||||
...toRefs(state),
|
||||
newsInfo,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user