Vue组件中的export作用

export起什么作用呢?

        作用一:在.vue文件中,通过定义export,可以开放这个组件中的变量或方法,给其它模块引用这个文件时,能够使用这些变量或方法。

        不得不说,Vue在Js的基础上,做了一个非常好的封装。举个jquery的例子:

       a.js: 

 function s(){
	return "a";
}

   b.js: 

 function s(){
	return "b";
}

index.html:

<!doctype html>
<html lang="en">
 <head>
      <meta charset="UTF-8" /> 
      <title>Document</title>
      <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js" ></script>
      <script src="a.js" ></script>
      <script src="b.js" ></script>

 </head>
 <body>
    hello!
 </body>
</html>

 结果:

 结果是,后面定义的js,会将前面js定义的方法覆盖。

使用export的时候,我们可以指定引用哪一个vue文件的哪个方法,从而避免冲突。

作用二、定义组件的属性、data等

比如我们的一个.vue组件component:

  <template>
  <div>
      <template  v-for="item in list" :key="item.id"> 
          <span>{{item.id}}:{{item.text}}</span>
      </template>
  </div>
   </template>
<script>
export default {
  name: 'AboutView',
  data(){
    return {
      list: [
        {
          id:"1",
          text:"张三"
        },
        {
          id:"2",
           text:"李四"
        },
        {
          id:"3",
          text:"王五"
        }
      ] 
    }
  }
}
</script> 

    我们动态调用这个components的时候,通过export还可以定义data。

        

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Advanced Data Export VCL is a component suite for Delphi and C++ Builder that allows you to save your data in the most popular data formats for the future viewing, modification, printing or web publication. You can export data into MS Access, MS Excel, MS Word (RTF), Open XML Format, Open Document Format (ODF), HTML, XML, PDF, TXT, DBF, CSV and more! There will be no need to waste your time on tiresome data conversion - Advanced Data Export will do the task quickly and will give the result in the desired format. Key Features Data export into 17 most popular formats: MS Access, MS Excel, MS Word, Open XML Format, Open Document Format (ODF), RTF, HTML, XML, PDF, TXT, DBF, CSV, SYLK, DIF, LaTeX, SQL and Windows Clipboard Support for 64-bit Windows target platform Export of Unicode data. Manually preset text encoding for exported data (UTF-8, UTF-16/UCS-2, UTF-32/UCS-4, Latin1, Latin2, Latin5, Latin7 and more) Saving data for future viewing, modification, printing or web publication Easy-to-use wizard allows your end-users to export data quickly Powerful export options for each data format 100% native Delphi code No additional libraries or software required to operate Detailed help system and demo application Powerful components and properties editors Delphi 5-7, 2005-2007, 2009, 2010, XE-XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo and C++ Builder 5-6, 2006-2007, 2009, 2010, XE-XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo support Setting the user formats for each field separately Multilanguage support

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jim-Zheng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值