Vue js应用程序代码引发错误(预期为Js)

时间:2019-07-11 00:09:21

标签: visual-studio vue.js

我正在尝试构建vue js应用程序,但出现以下错误。

严重性代码描述项目文件行抑制状态 警告TS1005(JS)':'。 VuejsApp JavaScript内容文件C:\ Users \ Khundokar Nirjor \ Documents \ Visual Studio 2017 \ Projects \ VuejsApp \ VuejsApp \ src \ App.vue 19有效

这是Home.vue代码

input %>% 
  complete(SS = 70:100, fill = list(raw = '-')) %>% 
  group_by(SS) %>% 
  filter(n() == 1| n() > 1 & row_number()  %in% c(1, n())) %>% 
  summarise(raw = str_c(raw, collapse = '-')) %>%
  arrange(desc(SS))

我想显示按钮列表,当我单击其中任何一个按钮时,我想显示按钮被单击的消息。

1 个答案:

答案 0 :(得分:0)

我相信您的错误与组件有关。首先,函数名称错误。正确的名称是Vue.component,它的名称是Vue.components。其次,您的组件声明不正确。

我创建了this codepen,您可以在其中查看如何在全局和本地声明组件。

const buttonCounter = {
	template:
		`<button @click="displayLanguage(item)">
			<span style="font-size:25px;">{{ item }}</span>
		</button>`,
	props: ["item"],
	methods: {
		displayLanguage: function(lng) {
			this.$emit("show-language", lng);
		}
	}
}


// Declare your component globally, will be able to access it in any another component in the application
Vue.component("button-counter", buttonCounter );

new Vue({
	el: "#databinding",
  // declarete your component locally, it only will be available inside this context
	components:{
		'button-counter-2' : buttonCounter
	},
	data: function() {
		return {
			languageclicked: "",
			languages: ["Java", "PHP", "C++", "C", "Javascript", "C#", "Python", "HTML"]
		};
	},
	methods: {
		languageDisp: function(a) {
			this.languageclicked = a;
		}
	}
});
body {
	margin: 20px;
}

.btn-wrapper {
		display: flex;
		margin-bottom: 20px;
	}
	
	
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="databinding">
	<div id="counter-event-example">
		<p style="font-size:25px;">Language displayed : <b>{{ languageclicked }}</b></p>
		<div class="btn-wrapper">
			<button-counter v-for="(item, index) in languages" :item="item"  :key="item" @show-language="languageDisp"/>
		</div>
		<button-counter-2 v-for="(item, index) in languages" :item="item" :key="item"  @show-language="languageDisp"/>
	</div>
</div>