모바일 장치에서 VueJS를 실행하는 데 문제가 있습니다.VueJS가 모바일에서 작동하지 않습니다.
http://codepen.io/techcater/pen/xOZmgv
HTML 코드 : 나는 여기에 프로젝트에 대한 링크입니다 copepen.io
에 기상 예측 응용 프로그램을 만들어
<div class="container-fluid text-center">
<h1>Your Local Weather</h1>
<p>
{{location}}
</p>
<p>
{{temperature}}
<a @click="changeDegree">{{degree}}</a>
</p>
<p>
{{weather | capitalize}}
</p>
<img :src="iconURL" alt="" />
<br>
<a href="https://ca.linkedin.com/in/dalenguyenblogger" target="_blank">by Dale Nguyen</a>
<!-- <pre>{{$data | json}}</pre> -->
</div>
JS 코드 :
new Vue({
el: '.container-fluid',
data: {
location: "",
temperature: "",
degree: "C",
weather: "",
iconURL: ""
},
created: function(){
this.getWeather();
},
methods: {
getWeather: function(){
var that = this;
this.$http.get("http://ipinfo.io").then((response) => {
console.log(response.data);
that.location = response.data.city + ", " + response.data.country;
// Get weather informaiton
var api = 'ebd4d312f85a230d5dc1db91e20c2ace';
var city = response.data.city;
var url = "http://api.openweathermap.org/data/2.5/weather?q={CITY}&APPID={APIKEY}&units=metric";
url = url.replace("{CITY}",city);
url = url.replace("{APIKEY}", api);
that.$http.post(url,{dataType: 'jsonp'},{
headers : {
'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
}}).then((response) => {
console.log(response.data);
that.temperature = response.data.main.temp;
that.weather = response.data.weather[0]['description'];
that.iconURL = "http://openweathermap.org/img/w/" + response.data.weather[0]['icon'] + ".png";
}, (response) => {
// error callback
});
}, (response) => {
console.log(response.data);
});
},
changeDegree: function() {
if(this.degree == "C"){
this.degree = "F";
this.temperature = Math.round((this.temperature*9/5 + 32)*100)/100;
}else {
this.degree = "C";
this.temperature = Math.round(((this.temperature - 32)*5 /9)* 100)/100;
}
}
}
})
노트북에서는 잘 작동하지만 모바일에서는 정상적으로 작동하지 않습니다. 처음에는 Codepen 덕분이라고 생각했습니다. 사이트를 돌 때 뭔가가 발생할 수 있습니다. 그러나, 내 웹 사이트에서 프로젝트를 만들 때도 작동하지 않습니다.
문제를 찾을 수 있습니까? 감사합니다,
정확하게 이동 장치에 실패 뭐죠 :
여기서 새로운 코드는? –
휴대 기기는 무엇입니까? Safari iOS, Android? – gurghet
@YerkoPalma 아이폰을 사용하고 있으며 사파리와 크롬 브라우저를 사용해 보았습니다. –