So I am creating an app for a school project and I am trying to make a navigation screen.
I have a screen with 2 buttons and I am trying to make them work. If I click/press on the button I want to go to a diffrent screen.
I am new to this, this is the first time I am using Vue Native.
Current code:
<template>
<div id="app">
<HelloWorld msg="CarnavalXL"/>
<div id="nav">
<button #press="goToParadeScreen" class="nav-button">Optochten</button>
<button href="screens/Parades.vue" class="nav-button" title="Niews">Nieuws</button>
<router-link to="Parades" class="nav-button">Parades</router-link>
</div>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'CarnavalXL',
components: {
HelloWorld,
AppNavigator
},
props: {
navigation: {
type: Object
}
},
methods: {
goToPAradeScreen() {
this.navigation.navigate("Parades");
}
}
}
import {
createAppContainer,
createStackNavigator,
} from "vue-native-router";
import Parades from "./Parades.vue";
this.navigation.navigate("Parades", {/* options go here */});
const StackNavigator = createStackNavigator(
{
Parades: Parades,
},
{
initialRouteName: 'Parades',
}
);
const AppNavigator = createAppContainer(StackNavigator);
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
margin-left: 25vw;
margin-right: 25vw;
}
.nav-button {
background-color: rgba(0, 0, 0, 0.3);
padding: 100px 0px;
width: 20vw;
display: inline-block;
margin: 5px;
color: #fff;
font-size: 40px;
font-weight: 800;
}
</style>
I get the following error:
Failed to compile.
./src/App.vue
Module Error (from ./node_modules/eslint-loader/index.js):
D:\carnavalxl\src\App.vue
19:5 error The "AppNavigator" component has been registered but not used vue/no-unused-components
β 1 problem (1 error, 0 warnings)
I followed the guide on the site of Vue Native
I do not know what is going wrong here
It's because your only importing the HelloWord component and not importing AppNavigator component. If you have a component called AppNavigator you have to import it like the HelleWorld like this:
import HelloWorld from './components/HelloWorld.vue'
Related
I was trying to deploy my react app with firebase deploy. I accidentally clicked yes to the prompt: File build/index.html already exists. Overwrite? (y/N).
Now my index html is this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Firebase Hosting</title>
<!-- update the version number as needed -->
<script defer src="/__/firebase/8.2.3/firebase-app.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/8.2.3/firebase-auth.js"></script>
<script defer src="/__/firebase/8.2.3/firebase-database.js"></script>
<script defer src="/__/firebase/8.2.3/firebase-messaging.js"></script>
<script defer src="/__/firebase/8.2.3/firebase-storage.js"></script>
<!-- initialize the SDK after all desired features are loaded -->
<script defer src="/__/firebase/init.js"></script>
<style media="screen">
body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; }
#message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
#media (max-width: 600px) {
body, #message { margin-top: 0; background: white; box-shadow: none; }
body { border-top: 16px solid #ffa100; }
}
</style>
</head>
<body>
<div id="message">
<h2>Welcome</h2>
<h1>Firebase Hosting Setup Complete</h1>
<p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p>
<a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a>
</div>
<p id="load">Firebase SDK Loadingβ¦</p>
<script>
document.addEventListener('DOMContentLoaded', function() {
// // π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯
// // The Firebase SDK is initialized and available here!
//
// firebase.auth().onAuthStateChanged(user => { });
// firebase.database().ref('/path/to/ref').on('value', snapshot => { });
// firebase.messaging().requestPermission().then(() => { });
// firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { });
//
// // π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯
try {
let app = firebase.app();
let features = ['auth', 'database', 'messaging', 'storage'].filter(feature => typeof app[feature] === 'function');
document.getElementById('load').innerHTML = `Firebase SDK loaded with ${features.join(', ')}`;
} catch (e) {
console.error(e);
document.getElementById('load').innerHTML = 'Error loading the Firebase SDK, check the console.';
}
});
</script>
</body>
</html>
When I go to the url where my app is deployed, it shows this firebase welcome html. I realize I wasn't supposed to overwrite my html but how can I get my html back?
From the "Hosting" part of the Firebase console you can rollback previously deployed versions.
Under the "Dashboard" tab, there is a section named "--your_project_id-- release history" which shows the list of deployed versions. At the end of each line there is a three dots button. Click on it and choose the "Rollback" option.
I have Vue single-file component which displays a product's details (well its meant to anyway). All my data seems to be loading fine from a Vuex store. This is my Product.vue page:
<template>
<div class="page-content">
{{Product}} <!-- this works and shows JSON on the page -->
{{Product.ProductTitle}} <!-- this shows nothing at all -->
</div>
</template>
<script>
import {mapGetters} from 'vuex';
export default {
name: "Product",
computed:
{
...mapGetters({
Product: 'getProduct',
})
},
serverPrefetch() {
return this.getProduct();
},
mounted() {
if (!this.Product.length) {
this.getProduct();
}
},
methods: {
getProduct() {
return this.$store.dispatch('loadProduct', {ProductID: this.$route.params.ProductID})
}
}
}
</script>
The data in the computed Product variable is just this:
[ { "ProductID": 12552, "ProductTypeID": 1, "ProductStatusID": 3, "ProductTitle": "Sony PlayStation 4 Pro" }]
I cannot fathom out why {{Product}} displays the whole JSON object, but {{Product.ProductTitle}} shows nothing?
UPDATE: JSFiddle showing problem
You have an object inside array inside array e.g.: [[{}]] so you have to get the data like this: {{Product[0][0].ProductTitle}}
new Vue({
el: "#app",
data: {
Product: [
[{
"ProductID": 14896,
"ProductStatusID": 3,
"CountryID": 207,
"ProductTitle": "PS4 Pro Console + Call of Duty: Modern Warfare / Death Stranding + Metro Exodus",
"ProductItemDescription": "<p>The best PS4 Pro bundle offer!</p>"
}]
]
}
})
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h1 {
color: black
}
h2 {
color: blue;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<article role="article" class="">
<h1>
{{Product[0][0].ProductTitle}}
<!-- this doesn't work? -->
</h1>
<h2>
{{Product}}
</h2>
</article>
</div>
I have tried to add background Image in my application using inline CSS styling but I'm unable to add in semantic-ui-react component and also the div.
Tried by backgroundImage:url(${https://wallpapercave.com/wp/wp2449777.png}) using this in my div and also the component called in semantic-ui-react
import React,{Component} from 'react';
import {Container,Image,Segment} from 'semantic-ui-react';
import Certificate from '../ethereum/certificate';
import web3 from '../ethereum/web3';
class certificateHere extends Component{
static async getInitialProps(props){
const numberofCertificates = await Certificate.methods.getCertificateCount().call();
const recentCertificate = await Certificate.methods.certificates(numberofCertificates-1).call();
return { numberofCertificates , recentCertificate};
}
render(){
const { numberofCertificates , recentCertificate}= this.props;
return (
<div className='main'
style={{
textAlign:'center',
backgroundImage:`url(${https://wallpapercave.com/wp/wp2449777.png})`
}}
>
<Segment >
<div className='sub'>
<h1><b>Blockchain Certification</b></h1>
<h3 >This is to certify that</h3><br/>
<p><b>{recentCertificate.CandidateName} has successfully completed his {recentCertificate.CourseName} developer Program which<br/>
is of 14 hrs online course: Build projects using solidity on {recentCertificate.DateOfCompletion}.</b></p>
</div>
<Image src='' size='small' style={{ marginLeft: 'auto', marginRight: 'auto'}} />
<div style={{ position: 'absolute',
bottom: '8px',
left: '16px'}}
>
<h4 className='issued'style={{textAlign:'left', textDecoration: 'underline'}}>Issued by:{recentCertificate.InstituteName}</h4>
<h4 className='location'style={{textAlign:'left',textDecoration: 'underline'}}>Location:{recentCertificate.Location}</h4>
</div>
<div style={{ position: 'absolute',
bottom: '8px',
right: '16px'}}>
<h4 className='issuer'style={{textAlign:'right',textDecoration: 'underline'}}>Issuer Name:{recentCertificate.IssuerName}</h4></div>
<style jsx>{`
h1 {
color: orange;
font-style: oblique;
font-size: 50px;
}
h3{
font-size: 40px;
color:orange;
padding-top: 25px;
}
p{
font-size: 20px;
color: orange;
padding:30px;
}
h4.issued{
color: orange;
padding-bottom: 25px;
}
h4.location{
padding-bottom: 100px;
}
h4.issuer{
padding-bottom: 100px;
}
.main{
backgroundColor:green;
}
`}</style>
</Segment>
</div>
);
}
}
export default certificateHere;
I just want the background image for this component covering the entire page.
Try using backgroundImage: βurl(https://wallpapercave.com/wp/wp2449777.png)β
I am migrating my app from Polymer 1 to Polymer 3. I am starting off with the Polymer 3 sample app from polymer init. When I re-arrange the my-app.js(renamed to main-app.js) like my polymer 1 main-app.html, the selected iron page component doesn't show.
For instance, for view one I can see it is loaded and in the DOM, but it just will not show. Any ideas why? I don't think the app elements api/behavior have changed.
% cat main-app.js
import { PolymerElement, html } from '#polymer/polymer/polymer-element.js';
import { setPassiveTouchGestures, setRootPath } from '#polymer/polymer/lib/utils/settings.js';
import '#polymer/app-layout/app-drawer/app-drawer.js';
import '#polymer/app-layout/app-drawer-layout/app-drawer-layout.js';
import '#polymer/app-layout/app-header/app-header.js';
import '#polymer/app-layout/app-header-layout/app-header-layout.js';
import '#polymer/app-layout/app-scroll-effects/app-scroll-effects.js';
import '#polymer/app-layout/app-toolbar/app-toolbar.js';
import '#polymer/app-route/app-location.js';
import '#polymer/app-route/app-route.js';
import '#polymer/iron-pages/iron-pages.js';
import '#polymer/iron-selector/iron-selector.js';
import '#polymer/paper-icon-button/paper-icon-button.js';
import './my-icons.js';
// Gesture events like tap and track generated from touch will not be
// preventable, allowing for better scrolling performance.
setPassiveTouchGestures(true);
// Set Polymer's root path to the same value we passed to our service worker
// in `index.html`.
setRootPath(MainAppGlobals.rootPath);
class MainApp extends PolymerElement {
static get template() {
return html`
<style>
:host {
--app-primary: var(--paper-indigo-500);
--app-secondary-color: black;
--iron-selector-background-color: #fff;
--iron-selected: #c5cae9;
--menu-link-color: #111111;
--drawer-toolbar-border-color: 1px solid rgba(0, 0, 0, 0.22);
--drawer-menu-color: #ffffff;
--primary-text: rgba(255, 255, 255, .89);
--secondary-text-color: #737373;
--v-border: rgba(127, 127, 127, .62);
--button-text: rgba(0,0,0, .87);
--orange-text: rgb(255, 87, 34);
--invalid: #ff0076;
-icon-color: #616161;
--focus-text: rgba(0,0,0, 0.87);
--focus-label: rgba(63, 81, 181, 0.87);
display: block;
}
iron-pages {
height: 100%;
}
app-header {
color: #fff;
background-color: var(--app-primary);
}
app-header paper-icon-button {
--paper-icon-button-ink-color: white;
}
.app-name {
margin-left: 20px;
font-size: 24px;
font-weight: 300;
}
app-drawer {
border-right: 1px solid var(--v-border);
}
.drawer-list a {
#apply(--layout-horizontal);
#apply(--layout-center);
line-height: 40px;
text-decoration: none;
color: var(--menu-link-color);
font-family: 'Roboto', 'Noto', sans-serif;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-size: 14px;
font-weight: 400;
line-height: 24px;
min-height: 48px;
padding: 0 16px;
}
.drawer-list a.iron-selected {
color: var(--app-primary);
background: var(--iron-selected);
}
.left-bar-container {
height: 100%;
overflow: auto;
margin-top: 64px;
color: var(--secondary-text-color);
background-color: var(--drawer-menu-color);
}
.toolbar-drawer {
border-bottom: var(--drawer-toolbar-border-color);
#apply(--paper-font-title);
}
.spacer-line {
border-bottom: 1px solid rgba(0, 0, 0, 0.22);
padding: 10px 0 10px 0;
}
a > iron-icon {
margin-right: 33px;
color: var(--icon-color);
}
.close {
color: #eeff41;
text-transform: none;
}
</style>
<app-location route="{{route}}" url-space-regex="^[[rootPath]]">
</app-location>
<app-route route="{{route}}" pattern="[[rootPath]]:page" data="{{routeData}}" tail="{{subroute}}">
</app-route>
<app-header-layout has-scrolling-region="">
<app-header fixed effects="waterfall" slot="header" condenses="" reveals="" effects="waterfall">
<app-toolbar>
<paper-icon-button icon="menu" on-tap="_drawerToggle"></paper-icon-button>
<div main-title class="app-name">Dolphin</div>
</app-toolbar>
</app-header>
<app-drawer-layout fullbleed="">
<!-- Drawer Sections -->
<app-drawer id="drawer" no-focus-trap="false" slot="drawer" swipe-open="[[narrow]]">
<div class='left-bar-container'>
<iron-selector selected="[[page]]" attr-for-selected="name" class="drawer-list" role="navigation">
<a name="view1" href="[[rootPath]]view1">View One</a>
<a name="view2" href="[[rootPath]]view2">View Two</a>
<a name="view3" href="[[rootPath]]view3">View Three</a>
</iron-selector>
</div>
</app-drawer>
<!-- Main content -->
<iron-pages selected="[[page]]" attr-for-selected="name" role="main">
<my-view1 name="view1"></my-view1>
<my-view2 name="view2"></my-view2>
<my-view3 name="view3"></my-view3>
<my-view404 name="view404"></my-view404>
</iron-pages>
</app-drawer-layout>
</app-header-layout>
`;
}
static get properties() {
return {
page: {
type: String,
reflectToAttribute: true,
observer: '_pageChanged'
},
routeData: Object,
subroute: Object
};
}
static get observers() {
return [
'_routePageChanged(routeData.page)'
];
}
_routePageChanged(page) {
// Show the corresponding page according to the route.
//
// If no page was found in the route data, page will be an empty string.
// Show 'view1' in that case. And if the page doesn't exist, show 'view404'.
if (!page) {
this.page = 'view1';
} else if (['view1', 'view2', 'view3'].indexOf(page) !== -1) {
this.page = page;
} else {
this.page = 'view404';
}
// Close a non-persistent drawer when the page & route are changed.
if (!this.$.drawer.persistent) {
this.$.drawer.close();
}
}
_pageChanged(page) {
// Import the page component on demand.
//
// Note: `polymer build` doesn't like string concatenation in the import
// statement, so break it up.
switch (page) {
case 'view1':
import('./my-view1.js');
break;
case 'view2':
import('./my-view2.js');
break;
case 'view3':
import('./my-view3.js');
break;
case 'view404':
import('./my-view404.js');
break;
}
}
}
window.customElements.define('main-app', MainApp);
I figured it out.... main-app had no height to it. The difference between Polymer 1 and Polymer 3 in my app was the shadow dom encapsulation for styling.
I'm building a Vue component as a Single File Component:
<template>
<div class="chart"></div>
</template>
<script>
import * as d3 from 'd3';
export default {
data() {
return {
data: [4, 8, 15, 16, 23, 42],
};
},
mounted() {
d3.select('.chart')
.selectAll('div')
.data(this.data)
.enter()
.append('div')
.style('width', d => `${10 * d}px`)
.text(d => d);
},
};
</script>
<style lang="scss" scoped>
.chart {
div {
background-color: steelblue;
color: white;
font: 10px sans-serif;
margin: 1px;
padding: 3px;
text-align: right;
}
}
</style>
After processing with webpack, the CSS is rendered like so:
<style type="text/css">
.chart div[data-v-xxxxxxxx] {
background-color: steelblue;
color: white;
font: 10px sans-serif;
margin: 1px;
padding: 3px;
text-align: right;
}
</style>
But the HTML shows up as:
<div data-v-xxxxxxxx class="chart">
<div style="width: 40px;">4</div>
<div style="width: 80px;">8</div>
<div style="width: 150px;">15</div>
<div style="width: 160px;">16</div>
<div style="width: 230px;">23</div>
<div style="width: 420px;">42</div>
</div>
I'm using D3 to generate the child <div>s. I've found that data-v-xxxxxxxx isn't bound to generated elements. If I include the child <div>s in the original template rather than generating them, they each have the data-v-xxxxxxxx attribute and the styles apply as expected
I would think that any descendant of the root node, whether included in the template or generated, should be bound to the rules of the scoped CSS. Is there any way to force this?
New version of vue-loader (from version 12.2.0) allows you to use "deep scoped" css. You need to use it that way:
<style scoped> now support "deep" selectors that can affect child
components using the >>> combinator:
.foo >>> .bar { color: red; } will be compiled into:
.foo[data-v-xxxxxxx] .bar { color: red; }
More informations on the release page of vue-loader