Skip to content

Instantly share code, notes, and snippets.

@muratbaseren
Last active February 12, 2023 06:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save muratbaseren/23692454ea255d38a5a66a233d9bd6b1 to your computer and use it in GitHub Desktop.
Save muratbaseren/23692454ea255d38a5a66a233d9bd6b1 to your computer and use it in GitHub Desktop.
Hygen VueJS Component Template
Hygen VueJS Component Template

Hygen VueJS Component Template

Create Hygen Template

  • hygen init self
  • hygen generator new --name component

Oluşan dosyaya yukarıdaki kodları ekle.

Use in Project

  • hygen component new --name component-name
---
to: src/components/<%=name%>.vue
---
<template>
<div class="<%=name%>" :title="message" @click="myalert">
<div>{{ text }}</div>
<div>
<icon name="check-circle" scale="2" />
</div>
</div>
</template>
<script>
// to use vue-awesome should run npm install vue-awesome command.
import "vue-awesome/icons";
import Icon from "vue-awesome/components/Icon";
export default {
name: "<%=name%>",
props: ["message"],
components: {
icon: Icon
},
data() {
return {
text: "<%=name%> component"
};
},
methods: {
myalert() {
alert(this.message);
}
},
created() {
this.text += ", click me!";
}
};
</script>
<style scoped>
.<%=name%> {
font-weight: bold;
color: #41b883;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment