在.vue文件中style是必须的吗?那script是必须的吗?为什么?
-
style 不是必须的,script 是必须的,而且必须要写上
export default {}
-
都不是必须的
如果是普通组件那么只能是一个静态html
如果是函数式组件, 那么可以直接使用props等函数式组件属性
https://cn.vuejs.org/v2/guide/render-function.html#%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BB%84%E4%BB%B6 -
style 不是必须的,script 是必须的,而且必须要写上
export default {}
可以不写的
-
试验了下,在 .vue 文件中,template是必须的,而script与style都不是必须的。
如果没有 template,则 [Vue warn]: Failed to mount component: template or render function not defined. -
试验了下,在 .vue 文件中,template是必须的,而script与style都不是必须的。
如果没有 template,则 [Vue warn]: Failed to mount component: template or render function not defined.提示说,在option上挂个render函数也可以,所以template也不是必须的。 可以这么说吧