laravel - 如何更正vuejs中的网址?
问题描述
我使用 axios 向http://localhost:8000/api/residence发送一个请求,之后我在我的页面中显示结果,当我想通过单击按钮移动到另一个页面时,我得到了错误的 url(当前 url + url请求 axios) 像这样**( http://localhost:8080/http://127.0.0.1:8000/residence/6 )** 我该如何解决这个问题。
<div class="col-md-6 col-lg-4" v-for="r in res.data">
<div class="card-body">
<h4 class="card-title">{{r.nom}} <br></h4>
</div>
<div>
<router-link :to="'/residence/' + r.id" class="btn btn-outline-primary
btn-sm btt">Full info</router-link>
</div>
</div>
axios.get('http://127.0.0.1:8000/api/residence?page=' + page)
.then(response => {
this.res = response.data.data;
});
解决方案
表格 :
<form @submit.prevent="addproperty()">
<div class="col-md-12">
<div class="form-group">
<label>Property Title</label>
<input type="text" name="property-title" class="form-control" placeholder="Property Title"required v-model="property_title">
</div>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
网址:
<script>
export default {
data() {
return {
property_title:null,
}
},
methods: {
addproperty() {
axios.post('addproperty',{title: this.property_title});
this.$router.push('/properties_list')
},
},
}
</script>
推荐阅读
- r - 如何将文本拆分为一列并使用 R 将每个拆分部分放入一个新的数据框中?
- python - 从源安装 Odoo:错误:找不到 pg_config 可执行文件
- ios - UIViewControllerRepresentable 在滚动视图中不接收焦点更新
- android - Xamarin Android FileProvider Java.Lang.IllegalArgumentException:找不到配置的根目录包含
- javascript - JavaScript & HTML:onclick 按钮运行 javascript 功能?
- python - Django 管理表单中的表情符号变成问号
- javascript - 如何使用 javascript 在我的网站中添加带有自定义标志的语言翻译器?
- php - 如何在多个下拉列表中显示选定的值?
- python - 对数线性回归
- computer-science - 如何使用给定频率的霍夫曼码获得字母表