0

I'm trying to set an extra css class for my object. In my props I have

customClass: {
        type: Object,
        default: function () {
            return {};
        },
    },

and I'm trying to set my customClass (custom-class) in my PHP code as such:

$('.ac-col-12.tokenizer-wrapper')
    .append('<tokenizer-wrapper :value=\'<?= json_encode($visit['tags']) ?>\' ' +
    'custom-class=\'{tag-visit}\''+
    'term=\'search\' label=\'<?= t('Tags'); ?>\' position=\'top\'>' +
"</tokenizer-wrapper>");

But I'm not passing the custom-class as a correct object so I'm receiving:

[Vue warn]: Invalid prop: type check failed for prop "customClass". Expected Object, got String.

How can I send the custom-class as object? suggestions?

9
  • You're missing the leading : on your custom-class attribute in the append() call. Commented Mar 15, 2018 at 17:46
  • @JohnEllmore but when I add : I have error: invalid expression: Unexpected token - in {tag-visit} Commented Mar 15, 2018 at 17:49
  • @Phiter cuz I have to? lol Commented Mar 15, 2018 at 17:49
  • @NickyMirfallah well, {tag-visit} isn't a valid JS object. Try replacing it with a valid object. Commented Mar 15, 2018 at 17:50
  • 1
    @NickyMirfallah something like {x: 1} is a valid object. Maybe you meant to say something like {"tag-visit": "somevalue"}? Commented Mar 15, 2018 at 17:54

1 Answer 1

1

You're missing the leading : on your custom-class attribute in the append() call. Also, make sure you're passing in a valid object; maybe you meant {"tag-visit": "somevalue"} instead of {tag-visit}?

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

Comments

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.