我正在编写vue.js应用程序,并使用npm安装了fullpage.js。我正在使用jquery来启动fullpage.js。我在这里遇到的问题是,当我尝试使用锚标记导航到页面中的不同部分时,它似乎无法正常工作。我正在为我的应用程序使用vue-cli Webpack模板,目前正在开发环境中本地运行它。
Contact.vue:
<template>
<main id="fullpage">
<section class="section contactDetails">
<div class="row">
<h1>Contact us</h1>
</div>
<div class="row">
<address>
Written by <a href="mailto:webmaster@example.com">Jon Doe</a>.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
</div>
<div class="row">
<button>{{directContactMsg}}</button>
<a href="#slide1">link to</a>
</div>
</section>
<section class="section contactForm" data-anchor="slide1">
<b-form-row>
<h1>{{clientMsg}}</h1>
</b-form-row>
<b-form-row>
<b-col>
<input type="radio" name="clientType" id="individual"> <label for="individual">an individual?</label>
</b-col>
<b-col>
<input type="radio" name="clientType" id="company"> <label for="company">a company?</label>
</b-col>
</b-form-row>
</section>
<section class="section contactForm">
<input type="email" placeholder="Email address..." class="text-center" required>
<button>Next step</button>
</section>
<section class="section contactForm">
<textarea name="" id="" cols="100" rows="7" placeholder="Message..."></textarea>
<button>Next step</button>
</section>
<section class="section contactForm">
<b-form>
<b-form-row>
<p>{{clientMsg}}</p>
</b-form-row>
<b-form-row>
<b-col>
<input type="radio" name="clientType" id="individual"> <label for="individual">an individual?</label>
</b-col>
<b-col>
<input type="radio" name="clientType" id="company"> <label for="company">a company?</label>
</b-col>
</b-form-row>
</b-form>
</section>
</main>
</template>
<script>
export default {
data(){
return {
"clientMsg":this.$store.state.contact.TypeOfClientMsg,
"directContactMsg":this.$store.state.contact.directContactMsg
}
}
}
</script>
<style>
.fp-tableCell{
text-align:center;
display:flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.contactDetails .row {
margin:0px;
}
.row {
justify-content: center;
align-items: center;
}
.contactForm .form-row {
min-width:500px;
justify-content:center;
}
</style>
main.js:
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import $ from "jquery"
import fullpage from 'fullpage.js'
import router from './router'
import store from './store'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import './assets/css/style.css';
import 'owl.carousel/dist/assets/owl.carousel.min.css';
import 'owl.carousel/dist/assets/owl.theme.default.min.css';
Vue.config.productionTip = false
Vue.use(BootstrapVue);
/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>',
router,
store
})
$(document).ready(()=>{
$('#fullpage').fullpage();
});
注意:我决定不使用fullpage-vue,因为我在模块上遇到了很多问题,并且文档中有错误。