Socket
Socket
Sign inDemoInstall

v-safe

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    v-safe

Vue.js directive to show text values from deep objects without any errors


Version published
Maintainers
1
Install size
5.91 kB
Created

Readme

Source

v-safe

Vue.js directive to show text values from deep objects without any errors

Version Github file size Downloads Vue2 Say Thanks!

Why

This is meant to avoid this type of error when you are using deep objects, that usually can happen when you're expecting a deep object after a Promise

<span>{{ a.b.c.d }}</span>

[Vue warn]: Error in render: "TypeError: Cannot read property 'c' of undefined"

How to install

npm

$ npm install v-safe --save

yarn

$ yarn add v-safe

Quick start

Vue.js

You can import in you main.js file

import Vue from 'vue'
import VSafe from 'v-safe'

Vue.use(VSafe)

Nuxt.js

You can import as a Nuxt.js plugin

~/plugins/v-safe.js

import Vue from 'vue'
import VSafe from 'v-safe'

Vue.use(VSafe)

and then import it in your nuxt.config.js file

plugins: [
  '~/plugins/v-safe.js'
]

Basic usage

<template>
  <span v-safe="'a.b.c.d'"></span>
</template>

<script>
export default {
  data:() => ({
    a: {
      b: {
        c: {
          d: 'safe'
        }
      }
    }
  })
}
</script>

Development

contributions welcome

Fork the project and enter this commands in your terminal

git clone https://github.com/YOUR_GITHUB_USERNAME/v-safe.git
cd v-safe
yarn

License

MIT © guastallaigor

Keywords

FAQs

Last updated on 24 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc