Skip to content

Instantly share code, notes, and snippets.

@techbysalma
techbysalma / emit.vue
Last active April 19, 2022 14:35
emit an event composition api
// child component
<template>
<input
@keyup="getData"
>
</template>
<script>
export default {
name: 'child',
@techbysalma
techbysalma / .eslintrc.js
Created March 24, 2022 13:27
eslint:recommended and plugin:vue/vue3-strongly-recommended
module.exports = {
root: true,
env: {
browser: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-strongly-recommended',
],
<template>
<div>
<span>{{ branch.label }}</span>
<span
v-show="hasChildren"
>
🌠
</span>
<!-- add toggle function to show or hide children -->
<!-- try to use a flat array -->
<template>
<render-component :key="count" />
<span @click="renderComponent">Click to reload render-component</span>
</template>
<script>
import { ref } from 'vue'
export default {
name: 're-render',
<template>
<el-dropdown trigger="click" ref="elDropDownRef">
<span class="el-dropdown-link">
Dropdown list
</span>
<template #dropdown>
<el-dropdown-menu @mouseleave="triggerHandle">
<el-dropdown-item>Action 1</el-dropdown-item>
<el-dropdown-item>Action 2</el-dropdown-item>
<el-dropdown-item>Action 3</el-dropdown-item>
@techbysalma
techbysalma / component.vue
Last active March 8, 2022 15:10
get current instance vuejs3
<script>
import { onMounted, getCurrentInstance } from 'vue'
export default {
name: 'Component',
props: {
name: {
type: String,
default: '',
<template>
<form @submit.prevent="action">
<label>Your name:
<input name="name" required>
</label>
<button :disabled="disabled">
Action
</button>
</form>
</template>