1. [Vue warn]: inject() can only be used inside setup() or functional components.
這個消息是提示我們,需要將引入的方法作為一個變量使用。以vue-store為例,如果我們按照如下的方式使用:
import UseUserStore from '../../store/modules/user'const role = UseUserStore ().role
就會提示如上錯誤。但是,如果我們按照這樣的方法使用,就不會報錯了。
import UseUserStore from '../../store/modules/user'const userStore = UseUserStore()
const role = userStore.role
2. [Vue warn]: Component inside renders non-element root node that cannot be animated.
這個warn是提示您,組件中的渲染元素沒有全部包裹在一個div中,就像下面這樣的:
只需要將這幾個引入的足跡放在根div標簽內即可:
當我們將渲染元素全部放在同一個div內,就沒有warn提示了。