Nativescript charts not displaying - nativescript

I am a newbie to Nativescript and currently working on a Nativescript project using javascript. I am exploring the charts option and have installed the nativescript UI charts using the 'tns plugin add nativescript-ui-chart' command. When I try to display a simple line chart I do not get any errors, but nothing gets displayed as well.
Here is my XML file:
<Page class="page coverImage" navigatingTo="onNavigatingTo" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:chart="nativescript-ui-chart">
<Label text="Test Charts Page"></Label>
<StackLayout>
<Label text="Test"></Label>
<chart:RadCartesianChart class="m-t-10" height="500">
<chart:RadCartesianChart.series>
<chart:LineSeries
items="{{ animeData }}"
categoryProperty="season"
valueProperty="count">
<chart:LineSeries.horizontalAxis>
<chart:CategoricalAxis labelFitMode="Rotate" />
</chart:LineSeries.horizontalAxis>
<chart:LineSeries.verticalAxis>
<chart:LinearAxis labelLayoutMode="Outer" />
</chart:LineSeries.verticalAxis>
</chart:LineSeries>
</chart:RadCartesianChart.series>
</chart:RadCartesianChart>
</StackLayout>
</Page>
My javascript file:
var frameModule = require("ui/frame");
var Observable = require("data/observable").Observable;
var pageData = new Observable();
pageData.animeData = [
{ season: "1", count: 82 }, { season: "2", count: 36 }, { season: "3", count: 41 },
{ season: "4", count: 52 }, { season: "5", count: 65 }, { season: "6", count: 40 },
{ season: "7", count: 52 }, { season: "8", count: 54 }, { season: "9", count: 47 },
{ season: "10", count: 52 }, { season: "11", count: 52 }, { season: "12", count: 53 },
{ season: "13", count: 34 }, { season: "14", count: 48 }, { season: "15", count: 49 },
{ season: "16", count: 45 }, { season: "17", count: 48 }, { season: "18", count: 45 },
{ season: "19", count: 47 }
];
exports.pageLoaded = function(args)
{
var page = args.object;
page.bindingContext = pageData;
};
I have added the nativescript-ui-chart to bundle.config as follows:
global.registerModule("nativescript-ui-chart",
() => require("../node_modules/nativescript-ui-chart"))
Package.json:
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.pregapp4",
"tns-ios": {
"version": "4.0.1"
}
},
"scripts": {
"lint": "eslint \"app/**/*.js\""
},
"dependencies": {
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-chart": "^3.9.1",
"nativescript-ui-dataform": "^3.7.3",
"nativescript-ui-listview": "^3.7.2",
"nativescript-ui-sidedrawer": "^4.3.1",
"tns-core-modules": "^5.0.2"
},
"devDependencies": {
"eslint": "~4.9.0",
"nativescript-dev-sass": "~1.5.0",
"nativescript-dev-webpack": "~0.10.0",
"webpack": "~3.10.0",
"webpack-bundle-analyzer": "^2.9.1",
"webpack-sources": "~1.1.0",
"clean-webpack-plugin": "~0.1.19",
"copy-webpack-plugin": "~4.3.0",
"raw-loader": "~0.5.1",
"css-loader": "~0.28.7",
"nativescript-worker-loader": "~0.8.1",
"resolve-url-loader": "~2.2.1",
"extract-text-webpack-plugin": "~3.0.2",
"uglifyjs-webpack-plugin": "~1.1.6",
"sass-loader": "~6.0.6"
}
}
On running this I donot get an errors, but just a blank white space - not sure what I am missing - any help will be appreciated..

Looks like data model is not getting set to Observable. I have changed the code to following in it's working fine for me on ios.
var observableModule = require("tns-core-modules/data/observable");
function HomeViewModel() {
var viewModel = observableModule.fromObject({
animeData: [
{ season: "1", count: 82 }, { season: "2", count: 36 }, { season: "3", count: 41 },
{ season: "4", count: 52 }, { season: "5", count: 65 }, { season: "6", count: 40 },
{ season: "7", count: 52 }, { season: "8", count: 54 }, { season: "9", count: 47 },
{ season: "10", count: 52 }, { season: "11", count: 52 }, { season: "12", count: 53 },
{ season: "13", count: 34 }, { season: "14", count: 48 }, { season: "15", count: 49 },
{ season: "16", count: 45 }, { season: "17", count: 48 }, { season: "18", count: 45 },
{ season: "19", count: 47 }
],
});
return viewModel;
}
module.exports = HomeViewModel;
Here is the playground link, in case you want to add something to this.

Looks like your plugin path needs to be fixed
<Page class="page coverImage" navigatingTo="onNavigatingTo" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:chart="nativescript ui-chart">
suppose to be
<Page class="page coverImage" navigatingTo="onNavigatingTo" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:chart="nativescript-ui-chart">

Related

Ansible search and query

Updated with suggestions from larsks.
With the following structure
"intf_output_ios": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"failed": false,
"gathered": [
{
"name": "GigabitEthernet0/0"
},
{
"mode": "trunk",
"name": "GigabitEthernet0/1",
"trunk": {
"allowed_vlans": [
"10",
"20",
"30",
"99",
"100"
],
"encapsulation": "dot1q"
}
},
{
"mode": "trunk",
"name": "GigabitEthernet0/2",
"trunk": {
"allowed_vlans": [
"10",
"20",
"30",
"99",
"100"
],
"encapsulation": "dot1q"
}
},
{
"access": {
"vlan": 30
},
"mode": "access",
"name": "GigabitEthernet0/3"
},
{
"name": "GigabitEthernet1/0"
},
{
"name": "GigabitEthernet1/1"
},
{
"name": "GigabitEthernet1/2"
},
{
"name": "GigabitEthernet1/3"
},
{
"name": "GigabitEthernet2/0"
},
{
"name": "GigabitEthernet2/1"
},
{
"name": "GigabitEthernet2/2"
},
{
"name": "GigabitEthernet2/3"
},
{
"name": "GigabitEthernet3/0"
},
{
"name": "GigabitEthernet3/1"
},
{
"name": "GigabitEthernet3/2"
},
{
"access": {
"vlan": 99
},
"mode": "access",
"name": "GigabitEthernet3/3"
}
]
}
To print only the ports in VLAN 30 use the following?
- name: "P901T6: Set fact to include only access ports - IOS"
set_fact:
access_ports_ios_2: "{{ intf_output_ios | json_query(query) }}"
vars:
query: >-
gathered[?access.vlan==`30`]
- name: "P901T7: Dump list of access ports - IOS"
debug:
var=access_ports_ios_2
NOTE: It is important to use 30 (with backticks) and not '30'
I have gone through https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#managing-list-variables without really understanding how to fix this. If someone has some good link that would be very useful
With a structure like
ok: [access01] => {
"access_ports_ios": [
{
"access": {
"vlan": 30
},
"mode": "access",
"name": "GigabitEthernet0/3"
},
{
"access": {
"vlan": 99
},
"mode": "access",
"name": "GigabitEthernet3/3"
}
]
}
To get ports in vlan 30 use:
- debug:
var: access_ports_ios|json_query(query)
vars:
query: >-
[?access.vlan==`30`]
Note:
If you want to use a variable for vlan instead of hard-coding it. I had to do as follows:
- name: Debug 4
debug:
var: access_ports_ios|json_query('[?access.vlan==`{{ src_vlan | int}}`]')
You're asking for gathered.access, but gathered is a list and does not have an access attribute. You want "all items from gathered for which access.vlan is 30 (and note that the value of access.vlan is an integer, not a string):
- debug:
var: intf_output_ios|json_query(query)
vars:
query: >-
gathered[?access.vlan==`30`]
Which given you example input produces:
TASK [debug] *******************************************************************
ok: [localhost] => {
"intf_output_ios|json_query(query)": [
{
"access": {
"vlan": 30
},
"mode": "access",
"name": "GigabitEthernet0/3"
}
]
}
I'm going to reiterate advice I often give for json_query questions: use something like jpterm or the JMESPath website to test JMESPath expressions against your actual data. This makes it much easier to figure out where an expression might be going wrong.

Heroku: There was an issue setting up your app environment. Name is invalid

When I try to use this app.json:
{
"stack": "heroku-18",
"repository": "https://github.com/OpenHumans/oh-data-source-template",
"logo": "https://avatars.githubusercontent.com/u/3341265?s=280&v=4",
"scripts": {
"postdeploy": "python manage.py init_proj_config"
},
"env": {
"SECRET_KEY": {
"description": "This is set for you and is used to encrypt data.",
"generator": "secret"
},
"OH_CLIENT_ID": {
"description": "See http://openhumans.org/direct-sharing/projects/manage",
"value": ""
},
"OH_CLIENT_SECRET": {
"description": "See http://openhumans.org/direct-sharing/projects/manage",
"value": ""
},
"OH_ACTIVITY_PAGE": {
"description": "See http://openhumans.org/direct-sharing/projects/manage",
"value": ""
},
"APP_BASE_URL ": {
"description": "e.g. https://your-app-name.herokuapp.com - no trailing slash!",
"value": "https://your-app-name.herokuapp.com"
},
"DEBUG": {
"description": "Displays detailed error info for web requests. Set False in production.",
"value": "false"
},
"HEROKU_APP": {
"description": "If true, ALLOWED_HOSTS is set to all.",
"value": "true"
}
},
"addons": [
"coralogix:free-30mbday",
"heroku-redis:hobby-dev",
{
"plan": "heroku-postgresql",
"options": {
"version": "9.5"
}
}
]
}
to deploy from:
https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fmikepsinn%2Foh-quantimodo-source
I get the error no matter what I set the name to:
I've tried adding the optional name field to the app.json but that doesn't help either.

Remove double quotes from Ansible fact

There is a json output which I am trying to parse. I registered the output into variable named instance_ip.
Here is the json output:
{
"msg": {
"instances": [
{
"root_device_type": "ebs",
"private_dns_name": "",
"cpu_options": {
"core_count": 2,
"threads_per_core": 1
},
"security_groups": [],
"state_reason": {
"message": "Client.UserInitiatedShutdown: User initiated shutdown",
"code": "Client.UserInitiatedShutdown"
},
"monitoring": {
"state": "disabled"
},
"ebs_optimized": false,
"state": {
"code": 48,
"name": "terminated"
},
"client_token": "test-Logst-14O6L4IETB05E",
"virtualization_type": "hvm",
"architecture": "x86_64",
"tags": {
"sg:environment": "TST",
"Name": "logstash1",
"aws:cloudformation:logical-id": "Logstash1A1594E87",
"sg:owner": "Platforms#paparapa.com",
"aws:cloudformation:stack-name": "test-three-ec2-instances-elk-demo",
"elastic_role": "logstash",
"sg:function": "Storage"
},
"key_name": "AWS_key",
"image_id": "ami-09f765d333a8ebb4b",
"state_transition_reason": "User initiated (2021-01-31 09:46:23 GMT)",
"hibernation_options": {
"configured": false
},
"capacity_reservation_specification": {
"capacity_reservation_preference": "open"
},
"public_dns_name": "",
"block_device_mappings": [],
"metadata_options": {
"http_endpoint": "enabled",
"state": "pending",
"http_tokens": "optional",
"http_put_response_hop_limit": 1
},
"placement": {
"group_name": "",
"tenancy": "default",
"availability_zone": "ap-southeast-2a"
},
"enclave_options": {
"enabled": false
},
"ami_launch_index": 0,
"ena_support": true,
"network_interfaces": [],
"launch_time": "2021-01-31T09:44:51+00:00",
"instance_id": "i-0fa5dbb869833d7c6",
"instance_type": "t2.medium",
"root_device_name": "/dev/xvda",
"hypervisor": "xen",
"product_codes": []
},
{
"root_device_type": "ebs",
"private_dns_name": "ip-10-x-x-x.ap-southeast-2.compute.internal",
"cpu_options": {
"core_count": 2,
"threads_per_core": 1
},
"source_dest_check": true,
"monitoring": {
"state": "disabled"
},
"subnet_id": "subnet-0d5f856afab8f0eec",
"ebs_optimized": false,
"iam_instance_profile": {
"id": "AIPARWXXVHXJWC2FL4AI6",
"arn": "arn:aws:iam::instance-profile/test-three-ec2-instances-elk-demo-Logstash1InstanceProfileC3035819-1F2LI7JM16FVM"
},
"state": {
"code": 16,
"name": "running"
},
"security_groups": [
{
"group_id": "sg-0e5dffa834a036fab",
"group_name": "Ansible_sec_group"
}
],
"client_token": "test-Logst-8UF6RX33BH06",
"virtualization_type": "hvm",
"architecture": "x86_64",
"public_ip_address": "3.x.x.x",
"tags": {
"Name": "logstash1",
"aws:cloudformation:logical-id": "Logstash1A1594E87",
"srg:environment": "TST",
"aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-southeast-2:117557247443:stack/test-three-ec2-instances-elk-demo/ca8ef2b0-63ad-11eb-805f-02630ffccc8c",
"sg:function": "Storage",
"aws:cloudformation:stack-name": "test-three-ec2-instances-elk-demo",
"elastic_role": "logstash",
"sg:owner": "Platforms#paparapa.com"
},
"key_name": "AWS_SRG_key",
"image_id": "ami-09f765d333a8ebb4b",
"ena_support": true,
"hibernation_options": {
"configured": false
},
"capacity_reservation_specification": {
"capacity_reservation_preference": "open"
},
"public_dns_name": "ec2-3-x-x-x.ap-southeast-2.compute.amazonaws.com",
"block_device_mappings": [
{
"device_name": "/dev/xvda",
"ebs": {
"status": "attached",
"delete_on_termination": true,
"attach_time": "2021-01-31T10:22:21+00:00",
"volume_id": "vol-058662934ffba3a68"
}
}
],
"metadata_options": {
"http_endpoint": "enabled",
"state": "applied",
"http_tokens": "optional",
"http_put_response_hop_limit": 1
},
"placement": {
"group_name": "",
"tenancy": "default",
"availability_zone": "ap-southeast-2a"
},
"enclave_options": {
"enabled": false
},
"ami_launch_index": 0,
"hypervisor": "xen",
"network_interfaces": [
{
"status": "in-use",
"description": "",
"subnet_id": "subnet-0d5f856afab8f0eec",
"source_dest_check": true,
"interface_type": "interface",
"ipv6_addresses": [],
"network_interface_id": "eni-09b045668ac59990c",
"private_dns_name": "ip-10-x-x-x.ap-southeast-2.compute.internal",
"attachment": {
"status": "attached",
"device_index": 0,
"attachment_id": "eni-attach-0700cd11dfb27e2dc",
"delete_on_termination": true,
"attach_time": "2021-01-31T10:22:20+00:00"
},
"private_ip_addresses": [
{
"private_ip_address": "10.x.x.x",
"private_dns_name": "ip-10-x-x-x.ap-southeast-2.compute.internal",
"association": {
"public_ip": "3.x.x.x",
"public_dns_name": "ec2-3-x-x-x.ap-southeast-2.compute.amazonaws.com",
"ip_owner_id": "amazon"
},
"primary": true
}
],
"mac_address": "02:d1:13:01:59:b2",
"private_ip_address": "10.x.x.x",
"vpc_id": "vpc-0016dcdf5abe4fef0",
"groups": [
{
"group_id": "sg-0e5dffa834a036fab",
"group_name": "Ansible_sec_group"
}
],
"association": {
"public_ip": "3.x.x.x",
"public_dns_name": "ec2-3-x-x-x.ap-southeast-2.compute.amazonaws.com",
"ip_owner_id": "amazon"
},
"owner_id": "117557247443"
}
],
"launch_time": "2021-01-31T10:22:20+00:00",
"instance_id": "i-0482bb8ca1bef6006",
"instance_type": "t2.medium",
"root_device_name": "/dev/xvda",
"state_transition_reason": "",
"private_ip_address": "10.x.x.x",
"vpc_id": "vpc-0016dcdf5abe4fef0",
"product_codes": []
}
],
"failed": false,
"changed": false
},
"_ansible_verbose_always": true,
"_ansible_no_log": false,
"changed": false
}
The goal is to get the private ip address and append the port number.
With the following task I got the list with node ip address ["10.x.x.x"]
- name: Getting EC2 instance ip address
set_fact:
instance_ip: "{{ logstash_instance | json_query('instances[*].network_interfaces[*].private_ip_address') | flatten }}"
With next task in a play I am trying to append the port number but I am keep getting
"['10.x.x.x:5044']"
- name: Get everything between quotes and append port 5044
set_fact:
logstash_hosts: "{{ instance_ip | map('regex_replace', '^(.*)$', '\\1:5044') | list }}"
Here is the template output:
# ------------------------------ Logstash Output -------------------------------
output.logstash:
hosts: "['10.x.x.x:5044']"
I need to get rid of the double quotes and pass the clean variable ['10.x.x.x:5044'] to my template file.
You can try creating a new list variable with the port number appended to each element, using this approach:
- set_fact:
logstash_hosts: "{{ logstash_hosts|default([]) + [ item ~ ':5044' ] }}"
with_items: "{{ instance_ip }}"
Then in template:
output.logstash:
hosts: {{ logstash_hosts|to_yaml }}
Also since the Logstash configuration is a YAML formatted file, you use YAML list syntax and directly use the instance_ip variable (and avoid set_fact). Then the template will look like this:
output.logstash:
hosts:
{% for ip in instance_ip %}
- {{ ip }}:5044
{% endfor %}

Possible bug NOT_AVAILABLE_IN_COUNTRY

I am trying to enable policy via Android Management API.
{
"name": "enterprises/LC03hx99sc/policies/default",
"version": "2",
"applications": [
{
"packageName": "app.caredirect.caredirecthub2",
"installType": "KIOSK"
},
{
"packageName": "com.android.settings",
"installType": "FORCE_INSTALLED",
"defaultPermissionPolicy": "GRANT"
},
{
"packageName": "com.amazon.dee.app",
"installType": "FORCE_INSTALLED",
"defaultPermissionPolicy": "GRANT"
}
],
"systemUpdate": {
"type": "WINDOWED",
"startMinutes": 10,
"endMinutes": 1439
},
"debuggingFeaturesAllowed": true
}
The store listing says for app.caredirect.caredirecthub2 that it is available in EVERY country.
Despite this I get the following error:
{
"name": "enterprises/LC03hx99sc/devices/33ddb8137f60b585",
"managementMode": "DEVICE_OWNER",
"state": "ACTIVE",
"appliedState": "ACTIVE",
"nonComplianceDetails": [{
"settingName": "applications",
"nonComplianceReason": "APP_NOT_INSTALLED",
"packageName": "app.caredirect.caredirecthub2",
"installationFailureReason": "NOT_AVAILABLE_IN_COUNTRY"
}, {
"settingName": "persistentPreferredActivities",
"nonComplianceReason": "APP_NOT_INSTALLED",
"packageName": "app.caredirect.caredirecthub2"
}],
"enrollmentTime": "2020-09-23T15:02:52.290Z",
"lastStatusReportTime": "2020-09-23T15:02:57.915Z",
"lastPolicySyncTime": "2020-09-23T15:02:53.754Z",
"appliedPolicyVersion": "1",
"apiLevel": 28,
"softwareInfo": {
"androidVersion": "9",
"androidDevicePolicyVersionCode": 1317100,
"androidDevicePolicyVersionName": "13.17.10.v32",
"androidBuildNumber": "TB-X605F_S210208_200807_ROW",
"deviceKernelVersion": "3.18.120-perf-g1d02637-dirty",
"bootloaderVersion": "unknown",
"androidBuildTime": "2020-08-07T10:08:52Z",
"securityPatchLevel": "2020-08-01",
"primaryLanguageCode": "en-US",
"deviceBuildSignature": "1c41fedecacbe89b81c242ecf74929f7d57322b64f8179c1c78a390a3494f14a",
"systemUpdateInfo": {
"updateStatus": "UP_TO_DATE"
}
},
"hardwareInfo": {
"brand": "Lenovo",
"hardware": "qcom",
"manufacturer": "LENOVO",
"serialNumber": "HA0Y8JQX",
"model": "Lenovo TB-X605F"
},
"appliedPolicyName": "enterprises/LC03hx99sc/policies/default",
"memoryInfo": {
"totalRam": "1909563392",
"totalInternalStorage": "3121049600"
},
"userName": "enterprises/LC03hx99sc/users/106404730049843005283",
"enrollmentTokenName": "enterprises/LC03hx99sc/enrollmentTokens/1019LI5YbxD4MNgIOfRKRxxKtK4ZLzRBZTGlL0Tw5Ns",
"previousDeviceNames": ["enterprises/LC03hx99sc/devices/3832aa78af19d796", "enterprises/LC03hx99sc/devices/326e9eaec5f835db", "enterprises/LC03hx99sc/devices/3f22065004da99b8", "enterprises/LC03hx99sc/devices/3027d6b05179f8ac", "enterprises/LC03hx99sc/devices/3011e18ade8e09f3", "enterprises/LC03hx99sc/devices/36ea1951ef4e088f", "enterprises/LC03hx99sc/devices/30fb71bc476a4d1d", "enterprises/LC03hx99sc/devices/3695657a941cba4a"],
"securityPosture": {
"devicePosture": "SECURE"
},
"ownership": "COMPANY_OWNED"
}
What is causing NOT_AVAILABLE_IN_COUNTRY ?
This is preventing the whole kiosk setup from working.
thanks

Image not displaying in loop Vue.js [duplicate]

This question already has answers here:
Vue.js dynamic images not working
(20 answers)
Closed 2 years ago.
I am trying to display 9 different images in a loop using v-for.
But, they are are not showing. If I show it without any loop, it works.
I am extracting the right resource but, still, it won't display.
This is my code:
<img class="list-complete-img" src="../assets/g1.jpg" alt="" /> //This works
<div v-for="item in data.items" :key="item.id">
<div>
{{ item.src }} // Just to check if I am printing right
</div>
<img class="list-complete-img" :src="item.src" :alt="item.src" /> // This does not work
</div>
Now the result that I am getting is:
This is my data.json:
"items": [
{ "id": "1", "src": "../assets/g1.jpg", "tags": ["all", "tag1"] },
{ "id": "2", "src": "../assets/g2.png", "tags": ["all", "tag2"] },
{ "id": "3", "src": "../assets/g3.png", "tags": ["all", "tag2"] },
{ "id": "4", "src": "../assets/g4.png", "tags": ["all", "tag1"] },
{ "id": "5", "src": "../assets/g5.png", "tags": ["all", "tag1"] },
{ "id": "6", "src": "../assets/g6.png", "tags": ["all", "tag2"] },
{ "id": "7", "src": "../assets/g7.jpg", "tags": ["all", "tag1"] },
{ "id": "8", "src": "../assets/g8.png", "tags": ["all", "tag2"] },
{ "id": "9", "src": "../assets/g9.png", "tags": ["all", "tag2"] }
]
EDIT
So far, I have observed that the problem lies with the src. If I am using an image link, it is working just fine. But, not with a local image(only if I used bunch of local images in a loop and working just fine in single). So, what I can do is put the file directory here. I would recommend if anyone of you can try on your local computer and try to upload images from your file directory in a loop and post it here.
SOLVED
It needed this statement exactly: require, the path directory and image name.
<div v-for="item in items" :key="item.id">
<div>
{{ item.src }}
</div>
<img
class="list-complete-img"
:src="require(`../assets/${item.src}`)"
:alt="item.src"
/>
</div>
This is issue has to do with the following quote of Evan You, which can be found here:
Because the imagePath is only rendered by Vue at runtime, Webpack has no chance of rewriting it.
Your JavaScript code needs to be like this:
export default {
name: "App",
data: function () {
return {
items: [
{ id: "1", src: "logo.png", tags: ["all", "tag1"] },
{ id: "2", src: "logo.png", tags: ["all", "tag2"] },
{ id: "3", src: "logo.png", tags: ["all", "tag2"] },
{ id: "4", src: "logo.png", tags: ["all", "tag1"] },
{ id: "5", src: "logo.png", tags: ["all", "tag1"] },
{ id: "6", src: "logo.png", tags: ["all", "tag2"] },
{ id: "7", src: "logo.png", tags: ["all", "tag1"] },
{ id: "8", src: "logo.png", tags: ["all", "tag2"] },
{ id: "9", src: "logo.png", tags: ["all", "tag2"] },
],
};
},
methods: {
getImgUrl: function (imagePath) {
return require('#/assets/' + imagePath);
}
}
};
Afterwards, you need to call your getImgUrl function by passing the filename. Your HTML will be like this:
<div id="app">
<img class="list-complete-img" src="./assets/logo.png" />
<div v-for="item in items" :key="item.id">
<img class="list-complete-img" :src="getImgUrl(item.src)" />
</div>
</div>
Since I do not have access to your images, I have taken the liberty to use the Vue logo as an image.
In summary, the above problem has to do that when Vue compiles, it takes all the assets and puts them in another folder like the image below:
Follow this pattern and your example will also work. Enjoy!
EDIT: If you want, you can have your static assets placed in the public folder. In that way, you will be able to write static paths for your assets.
try this: v-for="(item, i) in items" :key="i"
you can use a for loop which may help correct me if I am wrong
To use dynamic images, use require(). Change what you have to this.
<div id="app">
<div v-for="item in data.items" :key="item.id">
<img ... :src="require(item.src)" />
</div>
</div>

Resources