Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 866 Bytes

20.04-custom.md

File metadata and controls

35 lines (28 loc) · 866 Bytes
layout title label permalink nav_order parent
page
Inserting Custom Attributes in Web-Components
Custom directives
/usage-web-components/custom-directive/
4
Usage

: Custom Directive

A custom directive will interpret in JS whatever you pass as value.

<template>
  <a :href="this.getUrl('144')">Visit Profile</a>
</template>
<script>
  export default class extends Lego {
    getUrl(id) { return `/user/${id}` }
  }
</script>

outputs

<a href="/user/144">Visit Profile</a>

Boolean attributes

Example: <input type=checkbox :checked="state.agreed" :required="state.mustAgree">. With the following state: this.state = { agreed: false, mustAgree: true } would render <input type=checkbox required="required">.