亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這是在 vue.js 中導入 gsap 的正確方法嗎(它可以工作,但這是“正確”的方法嗎?)

這是在 vue.js 中導入 gsap 的正確方法嗎(它可以工作,但這是“正確”的方法嗎?)

catspeake 2023-08-10 11:03:10
我對 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>
查看完整描述

1 回答

?
蝴蝶不菲

TA貢獻1810條經驗 獲得超4個贊

我不確定你從哪里學習,但你使用的是 GSAP 的舊語法。如果您使用 GSAP 的新語法,則無需導入除gsap您的情況之外的任何內容:


import { gsap } from "gsap";


export default {

? name: "MainTemplate",

? mounted() {

? ? const { box } = this.$refs;

? ? const timeline = gsap.timeline();


? ? timeline.to(box, { duration: 1, x: 200, rotation: 90, ease: 'back.inOut' })

? ? timeline.to(box, { background: 'green' }, '-=0.5')

? },

};

查看完整回答
反對 回復 2023-08-10
  • 1 回答
  • 0 關注
  • 221 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號