相同點(diǎn):
不同點(diǎn):
一、export的使用比喻index.js要使用test.js中的數(shù)據(jù),首先在test.js文件中進(jìn)行導(dǎo)出操作export function list() { alert("list"); } export function info() { alert("info"); } export let a=10; 在index.js文件進(jìn)行導(dǎo)入操作<template> <div> <div v-show="show">HelloWorld</div> <button @click="handleClick">Click</button> </div> </template> <script> import {list} from '@/components/common.js' export default { name: "test", data() { return { show: true }; }, methods: { handleClick: function() { list(); } } }; </script> 2、export default的使用test.js文件
index.js文件中: 注意:一個(gè)js文件是可以有多個(gè) export,但是一個(gè)js文件中只能有一個(gè)export default |
|