1.?(!) `this` has been rewritten to `undefined`
原因:這是因為打包后沒有給this指向window,導致this undefined,因此需要配置context參數來指定代碼執行環境的參數為window
解決:rollup.config.js文件中添加配置
module.exports = [{input: 'src/index.ts',output: [...],// 用來指定代碼執行環境的參數,解決this執行undefined問題 context: 'window'}
];