<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div id='app'>
<forth-login></forth-login>
<forth-login></forth-login>
<forth-login></forth-login>
<forth-login></forth-login>
</div>
<template id="forth">
<h1 v-if='isLogin'>
<button @click='isLogin = !isLogin'>登录</button>
登录/注册
</h1>
<h1 v-else>
<button @click='isLogin = !isLogin'>退出</button>
个人信息
</h1>
</template>
<script>
// 第一个参数为组件名称
Vue.component('forth-login', {
template: '#forth',
data() {
return {
isLogin: true
}
}
})
const vm = new Vue({
el: '#app',
data: {
isLogin: true
},
methods: {
},
})
</script>
</body>
</html>