我正在努力vue-router不滚动/导航到锚标记(例如#anchor:)。我在 Stack Overflow 上阅读了各种解决方案,但到目前为止还没有一个有效。
请在下面找到我现在使用的代码,该代码不起作用:
main.js
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/docs/1.0/:title",
component: Content,
name: "docs"
}
],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition;
}
if (to.hash) {
return { selector: to.hash };
}
return { x: 0, y: 0 };
},
});
Run Code Online (Sandbox Code Playgroud)
Content.vue(父组件)
<template>
<base-section
v-for="entry in $store.state.entries"
:key="entry.title"
lang="lang-markup"
:title="entry.title"
>
<template v-slot:sectionId>
<div :id="slugify(entry.title)"></div>
</template>
<template v-if="entry.content" v-slot:content>
<span v-html="entry.content"></span>
</template>
<template v-slot:examples>
<div v-html="entry.examples"></div> …Run Code Online (Sandbox Code Playgroud) 这个问题已经被问到了,但是,我仍然没有得到任何正常工作。
我试图在我的 Laravel 应用程序的管理面板中创建一个功能,允许用户粘贴广告代码,然后将在 Laravel 应用程序的特定部分呈现。
我已经有了我的看法:
<form action="{{ route('update.ads', $ads->id) }}" method="POST" class="form-horizontal">
{{ csrf_field() }}
<div class="form-group">
<label class="control-label col-sm-12" >Ad1 (Interstitial or popup on Homepage)</label>
<div class="col-sm-10">
<input type="text" name="ad1" id="ad1" class="form-control" value="{{ $ads->ad1 }}">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-12" >Ad2 (Video Page - Banner Desktop)</label>
<div class="col-sm-10">
<input type="text" name="ad2" id="ad2" class="form-control" value="{{ $ads->ad2 }}">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-12" >Ad3 (Video Page - Banner Mobile)</label>
<div class="col-sm-10">
<input type="text" name="ad3" id="ad3" …Run Code Online (Sandbox Code Playgroud)