1

What would be the proper way to do this in Vue?

const brand = 'op';

switch(brand)
{
    case 'ed':
        <style lang="sass" src="./ed.css"></style>
    break;
    case 'op':
        <style lang="sass" src="./op.css"></style>
    break;
    case 'go':
        <style lang="sass" src="./go.css"></style>
    break;
}

I have the style tags in the Vue app but I know I can't use the switch in that part other than the script tags.

1
  • The style tag does not accept a src attribute. You probably want a <link> tag. Commented Apr 12, 2018 at 16:43

1 Answer 1

2

There is no Vue way to do that. <style> tags do not take src attributes. <link> tags go only in the <head> section, and Vue operates on the <body>.

If you have single file components, and your css files are specific to them, you could make a mixin that defines the component functionality, and have three components that all use the mixin, but each has its own style. Then you could use a dynamic component to switch between them based on brand.

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

1 Comment

Thanks for the anser Roy J. I think I can do what I have in mind with Mixins.

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.