0

I was wondering how I could create new elements dynamically like buttons, labels, or textfields which are inside a layout.

I have the following markup:

<AbsoluteLayout ref="abs">
    <Label :text="L('UserClockIn.info.5')" top="10" left="10" />
    <Label class="stk-table-row-data" :text="clockInTimes[0]" top="10" left="100" />
    <Label class="stk-table-row-data" :text="clockInTimes[1]" top="10" left="165" />
    <Label class="stk-table-row-data" :text="clockInTimes[2]" top="10" left="230" />
</AbsoluteLayout>

I am using nativescript-vue with typescript, i want to create a element like another label or button and add it to the absolute layout.

1 Answer 1

1

Answered here.

import { Label } from "tns-core-modules/ui/label";

export default {
    methods: {
        addLabel() {
            var label = new Label();
            label.text = "my text";
            // label.top = 10;
            // label.left = 150;
            this.$refs.abs.nativeView.addChild(label);
        }
    }
}

Anyways, it looks like you're creating a grid. Have you considered using a GridLayout?

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.