3

I'm trying to render this directive using Render Function

<h2 v-tooltip.top="{ content: 'You have new messages.', classes: 'tooltip-info', offset: 15 }">
            some text
</h2>

Using this code inside function

return createElement('h2', {
                    directives: [
                        {
                            name: 'v-tooltip',
                            value: {
                                content: field.tooltip.content ? field.tooltip.content : field.tooltip,
                                classes: field.tooltip.class ? field.tooltip.class : 'tooltip-info',
                                offset: 15,
                            },
                            arg: 'top',
                        },
                    ],
                }, [field.title]);

but i get this error: [Vue warn]: Failed to resolve directive: v-tooltip

Am i missing something, field is object which might have content or class prop. So i set them if it has or go to default in the else.

v-tooltip is this directive https://github.com/Akryum/v-tooltip

2
  • name should be just tooltip if I am not mistaken Commented Nov 7, 2017 at 13:51
  • jesus thank you! answer it so i can accept the answer Commented Nov 7, 2017 at 14:04

1 Answer 1

7

As I mentioned in the comments, v-tooltip should be changed to tooltip.

When defining a directive in vuejs, the name does not need the v- prefix: example:

Vue.directive('focus', {
  inserted: function (el) {
    el.focus()
  }
})

the above directive can be then called as:

<input v-focus>

source

Sign up to request clarification or add additional context in comments.

2 Comments

How can we pass the options? Such as v-tooltip.bottom to place the tooltip on the bottom
@null Args should be used as v-my-directive:foo and accessed via second param of inserted, as follows: inserted: function (el, binding) { console.log(binding.arg) }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.