zoukankan      html  css  js  c++  java
  • vue单页面

    <!DOCTYPE html>
    <html>
    
    	<head>
    		<meta charset="UTF-8">
    		<title></title>
    	</head>
    
    	<body>
    		<div id="app">
    			<component :is="currentPage"></component>
    		</div>
    	</body>
    
    </html>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script type="text/javascript" src="../js/jquery-1.10.2.min.js" ></script>
    <script>
    	Vue.component("login", {
    		template: `<div id="a">123</div>`
    	});
    
    	Vue.component("register", {
    		template: `<div id="b">456</div>`
    	});
    
    	Vue.component("list", {
    		template: `<div id="c">789</div>`
    	});
    
    	const vm = new Vue({
    		el: "#app",
    		data: {
    			currentPage: "register"
    		},
    		created() {
    			window.onhashchange = () => {
    				this.goPage()
    			};
    		},
    		methods: {
    			goPage() {
    				switch(location.hash) {
    					case "#/login":
    						this.currentPage = "login";
    						break;
    					case "#/register":
    						this.currentPage = "register";
    						break;
    					case "#/list":
    						this.currentPage = "list";
    						break;
    				}
    			}
    		}
    	});
    	
    	$("#a").click(function(){
    		alert("11");
    	});
    	$("#b").click(function(){
    		alert("22");
    	});
    	$("#c").click(function(){
    		alert("33");
    	});
    </script>
    

      

  • 相关阅读:
    Leetcode 12. Integer to Roman
    Leetcode 133. Clone Graph
    Leetcode 199. Binary Tree Right Side View
    Leetcode 200. Number of Islands
    React通过Ajax获取数据
    canvas鼠标点击划线
    制作图片墙
    CSS制作翻牌特效
    输入框制作方法
    初来咋到
  • 原文地址:https://www.cnblogs.com/yyy251/p/14000467.html
Copyright © 2011-2022 走看看