0

I created a component which is supposed to display a font icon :

<template>
    <Image :src.decode="code" />
</template>

<script>
    const mapping = {wi_owm_200:"&#xf01e;",wi_owm_201:"&#xf01e;",wi_owm_202:"&#xf01e;"};
    
    export default {
        props: {
            icon: String,
        },
        data() {
            return {
                code: String,
            };
        },
        created() {
            this.code = 'font://' + mapping[this.icon];
        }
    };
</script>

In my main page I have this code calling my component :

<template>
    <page>
        <StackLayout>
            <myComponent icon="wi_owm_200" />
        </StackLayout>
    </page>
</template>

<script>
import myComponent from "./myComponent";

export default {
    components: {
        myComponent
    }
}
</script>

When I compile, instead of my pretty icon, I will get the code "&#xf01e"... Meanwhile, directly in my main page this will work out perfectly :

<Image src.decode="font://&#xe900;" />

Here is the playground, if you want to check it live

Any idea to make my component work ?

1 Answer 1

3

For Button dynamically I use :text="code" (instead of text.decode="& #xf164;"), where

code = String.fromCharCode(0xf164);

Try it for Image!

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.