vue项目1-pizza点餐系统9-axios实现数据存储

一、安装、引入axios

1、终端输入cnpm install axios

2、在main.js中引入 import axios from ‘axios’

3、配置路径

axios.defaults.baseURL = ‘https://order-app1.firebaseio.com/’

二、在register组件中写登陆方法

1、现在script中导入axios

import axios from ‘axios‘
2、实现方法
<script> import axios from ‘axios‘ export default { data(){ return{ email:‘‘, password:‘‘, confirmPassword:‘‘ } }, methods:{ onSubmit(){ if(this.password === this.confirmPassword){ const formData = { email:this.email, password:this.password, confirmPassword:this.confirmPassword } axios.post(‘/users.json‘,formData) .then(res => this.$router.push({ name:‘loginLink‘//直接跳转到登陆界面 }))//console.log(res) }else{ alert("两次密码不一致!") } } } } </script>

  

 

 

相关文章