vue 点击按钮改变页面显示内容

xiaoxiao2021-03-01  26

<!DOCTYPE html> <html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lodash@4.13.1/lodash.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue"></script> </head> <body> <div id="one"> <template v-if="loginType === 'username'"> <label>Username</label> <input placeholder="Enter your username" key="username-input"> </template> <template v-else> <label>Email</label> <input placeholder="Enter your email address" key="email-input"> </template> <button @click="change">change</button> </div> <script type="text/javascript"> var vm = new Vue({ el:'#one', data:{ loginType : 'username' }, methods:{ change:function(){ if(this.loginType=='username'){ this.loginType='email' } else{ this.loginType='username' } } } }) </script> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-3200024.html

最新回复(0)