Vue.js相关问题

1.methods:

监听click事件

methods:{

      clickFunction:function(){

      }

}

2.mounted:

页面初始化方法

mounted(){ 

}

执行顺序是子组件---父组件

3.props:

接收来自父组件的数据

props: {
   seller: {
        type: Object
    }
}

4.$emit 向父组件传值

   this.$emit('showCityName',data);

  触发父组件的showCItyName事件。

5. 切换tab页面时echarts图标宽度失效问题

展示内容用v-if来控制,确保tab先加载

6.文件上传

<a-button :loading="uploading"
type="primary"
@click="$refs.uploadIpt.click()"
>
<a-icon type="upload" /> 需求导入
</a-button>
<input ref="uploadIpt"
type="file"
style="display: none"
@change="uploadFileChange"
>

uploadFileChange(e) {
this.uploading = true
const file = e.target.files[0]
const data = new FormData()
data.append('file', file)
fun(data)
.then((res) => {
if (res) {
this.$message.success('')
this.init()
}
})
.finally(() => {
this.uploading = false
})
e.target.value = ''
}

 7. 文件下载方式

  1)按钮下载

   

<a-button class='down' @click='handelDown'>
    <i class='img'></i>
</a-button> 

handelDown() { window.open(除域名外的完整url}

2) a标签下载
<span class='down' >
   <a :href='downloadUrl'>
   </a>
    <i class='img'></i>
</span>


data() {
    return {
        downloadUrl: 除域名外的完整的url
    }
}
 
posted @ 2019-09-30 14:07  Mrs.Li&Zhang  阅读(1666)  评论(0)    收藏  举报