UNPKG

@szmg-fe/tarco

Version:

function library in Taro

21 lines (17 loc) 475 B
/* * @Description: getCurrentInstance * @Date: 2021-04-01 10:22:38 * @Author: Lemon * @LastEditTime: 2021-04-07 10:04:31 */ import Taro from './Taro'; // 但频繁调用它可能会导致问题。 // 因此推荐把 Taro.getCurrentInstance() 的结果在组件中保存起来,之后直接使用 const getCurrentInstance = () => { let inst; if (!inst) { inst = Taro.getCurrentInstance(); } return inst; }; export default getCurrentInstance;