Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript v-如果多个条件不起作用 {{weatherData.city} {{weatherData.weather} {{天气数据.温度}}摄氏度 最高温度:{{weatherData.tempMax}}摄氏度 最低温度:{{weatherData.tempMin}}摄氏度 湿度:{{weatherData.湿度}}}% 计算:{ i选择(){ if(this.weatherData.icon==“04n”| |“04d”){ this.weatherData.icon=“04d” } else if(this.weatherData.icon==“01d”| |“01n”){ 此.weatherData.icon=“01d” } else if(this.weatherData.icon==“11d”| |“11n”){ this.weatherData.icon=“11d” } else if(this.weatherData.icon==“50d”| |“50n”){ this.weatherData.icon=“50d” } else if(this.weatherData.icon==“13d”| |“13n”){ this.weatherData.icon=“13d” } else if(this.weatherData.icon==“09d”| |“09n”| |“10d”| |“10n”){ this.weatherData.icon=“09d” } 返回此.weatherData.icon }_Javascript_Vue.js - Fatal编程技术网

Javascript v-如果多个条件不起作用 {{weatherData.city} {{weatherData.weather} {{天气数据.温度}}摄氏度 最高温度:{{weatherData.tempMax}}摄氏度 最低温度:{{weatherData.tempMin}}摄氏度 湿度:{{weatherData.湿度}}}% 计算:{ i选择(){ if(this.weatherData.icon==“04n”| |“04d”){ this.weatherData.icon=“04d” } else if(this.weatherData.icon==“01d”| |“01n”){ 此.weatherData.icon=“01d” } else if(this.weatherData.icon==“11d”| |“11n”){ this.weatherData.icon=“11d” } else if(this.weatherData.icon==“50d”| |“50n”){ this.weatherData.icon=“50d” } else if(this.weatherData.icon==“13d”| |“13n”){ this.weatherData.icon=“13d” } else if(this.weatherData.icon==“09d”| |“09n”| |“10d”| |“10n”){ this.weatherData.icon=“09d” } 返回此.weatherData.icon }

Javascript v-如果多个条件不起作用 {{weatherData.city} {{weatherData.weather} {{天气数据.温度}}摄氏度 最高温度:{{weatherData.tempMax}}摄氏度 最低温度:{{weatherData.tempMin}}摄氏度 湿度:{{weatherData.湿度}}}% 计算:{ i选择(){ if(this.weatherData.icon==“04n”| |“04d”){ this.weatherData.icon=“04d” } else if(this.weatherData.icon==“01d”| |“01n”){ 此.weatherData.icon=“01d” } else if(this.weatherData.icon==“11d”| |“11n”){ this.weatherData.icon=“11d” } else if(this.weatherData.icon==“50d”| |“50n”){ this.weatherData.icon=“50d” } else if(this.weatherData.icon==“13d”| |“13n”){ this.weatherData.icon=“13d” } else if(this.weatherData.icon==“09d”| |“09n”| |“10d”| |“10n”){ this.weatherData.icon=“09d” } 返回此.weatherData.icon },javascript,vue.js,Javascript,Vue.js,每个组件都是SVG动画。我只想在语句为true时渲染一个。但v-if不支持乘法条件。有什么想法吗?每个天气都有图标代码,例如“01d”和“01n”意思是说白天和晚上都很清楚。但是我只需要使用一个SVG,如果它支持多种条件,例如,假设您有: <template> <div> <h2>{{weatherData.city}}</h2> <h3>{{weatherData.weather}}</h3> &l

每个组件都是SVG动画。我只想在语句为true时渲染一个。但v-if不支持乘法条件。有什么想法吗?每个天气都有图标代码,例如“01d”和“01n”意思是说白天和晚上都很清楚。但是我只需要使用一个SVG,如果它支持多种条件,例如,假设您有:

<template>
<div>
    <h2>{{weatherData.city}}</h2>
    <h3>{{weatherData.weather}}</h3>
    <rain-cloud v-if="iconSelect==='09d'"/>
    <sun-cloud v-if="iconSelect==='04d'"/>
    <sunshine v-if="iconSelect=='01d'"/>
    <thunder-cloud v-if="iconSelect=='11d'"/>
    <windy-cloud v-if="iconSelect=='50d'"/>
    <snow-cloud v-if="iconSelect=='13d'"/>
    <div class="container">
        <h2>{{weatherData.temperature}}°C</h2>
        <h4>max temperature: {{weatherData.tempMax}}°C</h4>
        <h4>min temperature: {{weatherData.tempMin}}°C</h4>
        <h4>humidity: {{weatherData.humidity}}%</h4>
    </div>
</div>
</template>

computed:{
        iconSelect(){
            if(this.weatherData.icon==="04n" || "04d"){
                this.weatherData.icon="04d"
            }
            else if(this.weatherData.icon==="01d"|| "01n"){
                this.weatherData.icon="01d"
            }
            else if(this.weatherData.icon==="11d"|| "11n"){
                this.weatherData.icon="11d"
            }
            else if(this.weatherData.icon==="50d"|| "50n"){
                this.weatherData.icon="50d"
            }
            else if(this.weatherData.icon==="13d"|| "13n"){
                this.weatherData.icon="13d"
            }
            else if(this.weatherData.icon==="09d"||"09n"||"10d"||"10n"){
                this.weatherData.icon="09d"
            }
            return this.weatherData.icon
 }
您将能够编写以下语句:

new Vue({
  el: '#app',
  data: {
    x: 1,
    y: 2
  }
})

v-如果
支持多种条件-例如,假设您有:

<template>
<div>
    <h2>{{weatherData.city}}</h2>
    <h3>{{weatherData.weather}}</h3>
    <rain-cloud v-if="iconSelect==='09d'"/>
    <sun-cloud v-if="iconSelect==='04d'"/>
    <sunshine v-if="iconSelect=='01d'"/>
    <thunder-cloud v-if="iconSelect=='11d'"/>
    <windy-cloud v-if="iconSelect=='50d'"/>
    <snow-cloud v-if="iconSelect=='13d'"/>
    <div class="container">
        <h2>{{weatherData.temperature}}°C</h2>
        <h4>max temperature: {{weatherData.tempMax}}°C</h4>
        <h4>min temperature: {{weatherData.tempMin}}°C</h4>
        <h4>humidity: {{weatherData.humidity}}%</h4>
    </div>
</div>
</template>

computed:{
        iconSelect(){
            if(this.weatherData.icon==="04n" || "04d"){
                this.weatherData.icon="04d"
            }
            else if(this.weatherData.icon==="01d"|| "01n"){
                this.weatherData.icon="01d"
            }
            else if(this.weatherData.icon==="11d"|| "11n"){
                this.weatherData.icon="11d"
            }
            else if(this.weatherData.icon==="50d"|| "50n"){
                this.weatherData.icon="50d"
            }
            else if(this.weatherData.icon==="13d"|| "13n"){
                this.weatherData.icon="13d"
            }
            else if(this.weatherData.icon==="09d"||"09n"||"10d"||"10n"){
                this.weatherData.icon="09d"
            }
            return this.weatherData.icon
 }
您将能够编写以下语句:

new Vue({
  el: '#app',
  data: {
    x: 1,
    y: 2
  }
})

您可以使用并查看。当安装组件时,您是否将whetherdata.icon设置为某个值?您可以使用并查看。当安装组件时,您是否将whetherdata.icon设置为某个值?