vue.js - 错误 : Uncaught TypeError: Vue. util.hyphenate 不是函数

标签 vue.js

我尝试使用 onsen ui 设置 vuejs,但收到此错误:

Error: Uncaught TypeError: Vue.util.hyphenate is not a function

这是完整的代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/onsen/2.1.0/css/onsenui.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/onsen/2.1.0/css/onsen-css-components.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.1/vue.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/onsen/2.1.0/js/onsenui.js">        </script>
  <script src="https://unpkg.com/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e686b7b3371706d7b706b775e2c302e302e337f726e767f302e" rel="noreferrer noopener nofollow">[email protected]</a>"></script>
</head>
<body>
  <div id="app"></div>
</body>
<script>
  var vm = new Vue({
    el: '#app',
    template:
      '<v-ons-page>\
         <v-ons-toolbar>\
           <div class="center"> Title </div>\
         </v-ons-toolbar>\
         <p style="text-align: center">\
           <v-ons-button @click="$notification.alert(\'Hello World!\')">Click</v-ons-button>\
         </p>\
       </v-ons-page>'
  });
</script>
</html>

我找不到这是已知问题。我也尝试过使用旧版本的 od vue,例如 2.0.0。

有人可以帮忙吗?

最佳答案

先生,我遇到了和你一样的错误,我正在尝试找到错误并解决它。 首先,下载“https://unpkg.com/[email protected]”,并将脚本dom的src更改为本地的。 然后你可以打开“[email protected]”并找到这些代码:

var register = function register(Vue, type, items) {
	  (0, _keys2.default)(items).forEach(function (key) {
	    var value = items[key];
	    key = Vue.util.hyphenate(key);
	    Vue[type](key, value);
	  });
	};

所以你可以看到“Vue.util.hyphenate”,但是现在vue没有这个功能。请使用此文件中的相同函数。

例如:

var register = function register(Vue, type, items) {
	  (0, _keys2.default)(items).forEach(function (key) {
	    var value = items[key];
	    var hyphenate = function hyphenate(string) {
	  		return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
		};
	    key = hyphenate(key);
	    Vue[type](key, value);
	  });
	};

我的英语很差,很抱歉占用您的时间。

关于vue.js - 错误 : Uncaught TypeError: Vue. util.hyphenate 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42577989/

相关文章:

javascript - VueJS 在渲染数据之前等待 Apollo

javascript - 加载新的 JSON 数据并替换 VueJS 中的旧数据

webpack - 如何让 Vue (vue cli 3) 正确处理 GraphQL 文件?

vue.js - 为什么我在 v-on 属性值中不需要 `this`?

javascript - vuejs - 使用谷歌地图的 Safari 浏览器导航

unit-testing - 如何使用 Vue Test Utils 测试全局事件总线?

html - 由于 div 的高度,页面没有从顶部开始

vue.js - vue中动态加载组件的方法

css - Bootstrap-vue:当您将鼠标悬停在工具提示本身(而不是按钮)上时如何隐藏 v-b-tooltip

javascript - 验证 : 2 rows in a card