// js 代碼
new Vue({
el: "#app",
data: {},
methods: {
get: function() {
this.$http.get("get.php", {
"a": 1,
"b": 2
}).then(function(res) {
alert(res.data);
}, function(res) {
alert(res.status);
})
}
}
})
----------
// php代碼 (本人對PHP一無所知)
// 變量之前加上@是因?yàn)椴患拥脑挄?huì)報(bào)一個(gè) undefined index :a的錯(cuò)
<?php
$a = @$_GET['a'];
$b = @$_GET['b'];
echo $a + $b
?>
After triggering the send event get, 0 is returned. In the example, 3 is returned. I have checked the code many times and it is exactly the same. Please solve it! Thanks!
ringa_lee
get request to pass parameters like this:
this.$http.get("get.php", {
params: {
"a": 1,
"b": 2
}
}).
Reference https://github.com/pagekit/vu...
The parameters of get should be added to the url, for example: get.php?a=1&b=2
This is the form of the parameters attached to the post method