Skip to content

Commit

Permalink
fix: 当在URL自定义输入搜索为空时,跳回首页
Browse files Browse the repository at this point in the history
  • Loading branch information
bianxuerui committed Oct 11, 2024
1 parent 0b8c3a3 commit 2aacdc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
<script>
export default {
name: 'SearchPage',
props: ['query'],
mounted() {
this.loadGoogleCSE();
this.setupResultsRenderedCallback(); // 注册渲染结果回调函数
if (!this.query) {
history.back();
}
},
methods: {
loadGoogleCSE() {
Expand Down
3 changes: 2 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const router = createRouter({
{
path: '/search',
name: 'Results',
component: Results
component: Results,
props: route => ({ query: route.query.q })
}
]
})
Expand Down

0 comments on commit 2aacdc7

Please sign in to comment.