沉睡的獅子 即將醒來 而世界將爲之震撼css
signup.htmlhtml
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="./css/style.css"> <!-- 開發環境版本,包含了有幫助的命令行警告 --> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <title>signup_ArthurSlog</title> </head> <body> <div id="signup-container"> <div>This is signup's page by ArthurSlog</div> <p>Singup</p> <form id="form" v-on:submit="addUser"> <br> <div> Account: {{ name }} <br> <input type="text" v-model="name" placeholder="username"> </div> <br> <br> <div> Password: {{ password }} <br> <input type="text" v-model="password" placeholder="password"> </div> <br> <br> <div> Again Password: {{ repassword }} <br> <input type="text" v-model="repassword" placeholder="repassword"> </div> <br> <br> <div> First Name: {{ firstname }} <br> <input type="text" v-model="firstname" placeholder="firstname"> </div> <br> <br> <div> Last Name: {{ lastname }} <br> <input type="text" v-model="lastname" placeholder="lastname"> </div> <br> <br> <div> Birthday: {{ birthday }} <br> <input type="text" v-model="birthday" placeholder="2000/08/08"> </div> <br> <br> <div> <span>Sex: {{ currentSex }}</span> <br> <input type="radio" id="sex" value="male" v-model="currentSex"> <label for="sex">male</label> <br> <input type="radio" id="sex" value="female" v-model="currentSex"> <label for="sex">female</label> </div> <br> <br> <div> <span>Age: {{ currentAge }}</span> <br> <select v-model="currentAge" id="age"> <option disabled value="">Select</option> <option v-for="age in ages">{{ age }}</option> </select> </div> <br> <br> <div> Wechart: {{ wechart }} <br> <input type="text" v-model="wechart" placeholder="wechart's name"> </div> <br> <br> <div> QQ: {{ qq }} <br> <input type="text" v-model="qq" placeholder="12345678"> </div> <br> <br> <div> Email: {{ email }} <br> <input type="text" v-model="email" placeholder="12345678@qq.com"> </div> <br> <br> <div> Contury: {{ contury }} <br> <input type="text" v-model="contury" placeholder="China"> </div> <br> <br> <div> Address: {{ address }} <br> <input type="text" v-model="address" placeholder="Guangzhou"> </div> <br> <br> <div> Phone: {{ phone }} <br> <input type="text" v-model="phone" placeholder="138********"> </div> <br> <br> <div> Websize: {{ websize }} <br> <input type="text" v-model="websize" placeholder="xxx.com"> </div> <br> <br> <div> Github: {{ github }} <br> <input type="text" v-model="github" placeholder="Github's URl"> </div> <br> <br> <div> Bio: {{ bio }} <br> <input type="text" v-model="bio" placeholder="This is the world~"> </div> <br> <br> <input type="submit" value="完成註冊"> </form> <a href="./index.html">Return index's page</a> <br> <br> <div> <ul> <li v-for="record in commits"> <span class="username"> {{ record }} </span> </li> </ul> </div> </div> <script src="./js/signup.js"></script> </body> </html>
signup.js前端
var host = 'http://127.0.0.1:3000/signup?'; var signup_container = new Vue({ el: '#signup-container', data: { name: '', password: '', repassword: '', firstname: '', lastname: '', birthday: '', sexs: ['male', 'female'], currentSex: 'male', ages: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18'], currentAge: '18', wechart: '', qq: '', email: '', contury: '', address: '', phone: '', websize: '', github: '', bio: '', commits: ['null', 'null'] }, methods: { addUser: function () { var xhr = new XMLHttpRequest() xhr.open('GET', host + 'name=' + this.name + '&password=' + this.password + '&firstname=' + this.firstname + '&lastname=' + this.lastname + '&birthday=' + this.birthday + '&sex=' + this.currentSex + '&age=' + this.currentAge + '&wechart=' + this.wechart + '&qq=' + this.qq + '&email=' + this.email + '&contury=' + this.contury + '&address=' + this.address + '&phone=' + this.phone + '&websize=' + this.websize + '&github=' + this.github + '&bio=' + this.bio, true) xhr.send() } } })
<form id="form" v-on:submit="addUser"> ... <input type="submit" value="完成註冊"> </form>
methods: { addUser: function () { var xhr = new XMLHttpRequest() xhr.open('GET', host + 'name=' + this.name + '&password=' + this.password + '&firstname=' + this.firstname + '&lastname=' + this.lastname + '&birthday=' + this.birthday + '&sex=' + this.currentSex + '&age=' + this.currentAge + '&wechart=' + this.wechart + '&qq=' + this.qq + '&email=' + this.email + '&contury=' + this.contury + '&address=' + this.address + '&phone=' + this.phone + '&websize=' + this.websize + '&github=' + this.github + '&bio=' + this.bio, true) xhr.send() } }
http://127.0.0.1:3000/signup?name=???&password=???... 這後面的依此類推,我就不寫了,由於很長
xhr.open('GET', host + 'name=' + name + '&password=' + password + '&firstname=' + firstname + '&lastname=' + lastname + '&birthday=' + birthday + '&sex=' + currentSex + '&age=' + currentAge + '&wechart=' + wechart + '&qq=' + qq + '&email=' + email + '&contury=' + contury + '&address=' + address + '&phone=' + phone + '&websize=' + websize + '&github=' + github + '&bio=' + bio, true)
XMLHttpRequest.send() 方法用於發送 HTTP 請求。若是是異步請求(默認爲異步請求),則此方法會在請求發送後當即返回;若是是同步請求,則此方法直到響應到達後纔會返回。XMLHttpRequest.send() 方法接受一個可選的參數,其做爲請求主體;若是請求方法是 GET 或者 HEAD,則應將請求主體設置爲 null。 若是沒有使用setRequestHeader()方法設置 Accept 頭部信息,則會發送帶有* / *的Accept 頭部。
node index.js