<!-- 动态加载 -->

<template>
  <div class="container-fluid">
    <div class="row">
      <button
        class="btn btn-success"
        @click="change1"
      >
        动态加载
      </button>
    </div>
  </div>
</template>

<script>	
export default {

  components: {

  },
  data: function () {
    return {
    };
  },
  methods: {
    change: function () {
      let filename = 'DynamicImport.js';
      import('./' + filename).then(({ counter, incCounter }) => {
        console.log(counter); //3
        incCounter();
        console.log(counter); //3
      });
    },

        
    change1: function () {
      let filename = null;
      for(let index = 1; index < 2; index ++){
        filename = 'DynamicImport' + index;
      }
      import('./' + filename).then(module => {
        module.default.helloworld();
        module.default['helloworld']();
      });
    },
  },
};
</script>

<style>

</style>
