我對 Vue.js 還很陌生,在讓庫正常工作時遇到了一些問題,但沒有收到“錯誤‘X’未定義 no-undef”消息。在這種情況下,未定義“Back”(它是 GSAP 的一部分),我認為“定義”Back 的唯一位置是導入中。這只是導入庫的方法嗎?我是否必須像這樣編寫導入中每個未定義的部分?它有效,但似乎沒有必要。<template> <div id="mainTemplate"> <h2>This is the MainTemplaye.vue Component</h2> <div ref="box" class="box"></div> </div></template><script>import { TimelineLite, Back } from "gsap";export default { name: "MainTemplate", mounted() { const { box } = this.$refs; const timeline = new TimelineLite(); timeline.to(box, 1, { x: 200, rotation: 90, ease: Back.easeInOut, }) timeline.to(box, 0.5, { background: 'green' },'-=0.5') },};</script><style>.box { height: 60px; width: 60px; background: red;}</style>
這是在 vue.js 中導入 gsap 的正確方法嗎(它可以工作,但這是“正確”的方法嗎?)
catspeake
2023-08-10 11:03:10