您好,登錄后才能下訂單哦!
示例 http://47.94.90.89/dist
1 安裝vue-cli
(1) 下載安裝node.js
(1) npm install -g cnpm --registry=https://registry.npm.taobao.org 換源
(1) cnpm install -g vue-cli 全局安裝vue-cli 已安裝則不用
(1) vue init webpack Vue-Project 初始化vue項目 使用webpack模板,項目名稱(自帶webpack)
(1) cnpm install 初始化 生成node_modules
(1) npm run dev
需要上線打包為 npm run build
2 配置路由 (router 目錄>index.js)
import ccc from '@/components/ccc'
Router.prototype.go = function (a) {
sessionStorage.isBack = true
if(a){
window.history.go(a)
}else{
window.history.go(-1)
}
}
window.addEventListener("popstate", function(e) {
sessionStorage.isBack = true
}, false);
Vue.use(Router)
3 app.vue中
(1)```
<transition :name="transitionName" >
<router-view class="child-view" ></router-view>
</transition>
</div>
(2)<script>
export default {
name: 'App',
data () {
return {
transitionName:'slide-left'
}
},
watch: {
'$route' (to, from) {
let isBack = eval(sessionStorage.isBack)
if (isBack) {
this.transitionName = 'slide-right'
} else {
this.transitionName = ' slide-left'
}
console.log(sessionStorage.isBack);
sessionStorage.isBack = false
}
},
}
</script>
<style>
*{
margin: 0 ;
padding: 0;
}
body,html{
width: 100%;
height: 100%;
}
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
width: 100%;
height: 100%;
text-align: center;
max-width: 750px;
margin: 0 auto;
overflow-x: hidden;
position: relative;
}
.child-view {
transition:all .3s ease;
position: absolute;
width: 100%;
}
.slide-left-enter,.slide-right-leave-active {
opacity:0;
-webkit-transform:translate(100%,0);
transform:translate(100%,0);
}
.slide-left-leave-active,.slide-right-enter {
opacity:0;
-webkit-transform:translate(-100%,0);
transform:translate(-100%,0);
}
</style>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。