Просмотр исходного кода

feat(runtime-core): more specific warning for failed v-on fallthrough

close #1001
Evan You 6 лет назад
Родитель
Сommit
ab844fd169
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      packages/runtime-core/src/componentRenderUtils.ts

+ 6 - 1
packages/runtime-core/src/componentRenderUtils.ts

@@ -107,11 +107,16 @@ export function renderComponentRoot(
           root.patchFlag |= PatchFlags.FULL_PROPS
         }
       } else if (__DEV__ && !accessedAttrs && root.type !== Comment) {
+        const hasListeners = Object.keys(attrs).some(isOn)
         warn(
           `Extraneous non-props attributes (` +
             `${Object.keys(attrs).join(', ')}) ` +
             `were passed to component but could not be automatically inherited ` +
-            `because component renders fragment or text root nodes.`
+            `because component renders fragment or text root nodes.` +
+            (hasListeners
+              ? ` If the v-on listener is intended to be a component custom ` +
+                `event listener only, declare it using the "emits" option.`
+              : ``)
         )
       }
     }