I am new with svelte and npm. I am triying to do my first app. I executed npx degit... npm install and npm install svete-spa-router --save.
My page is ok, but when I do click on ref link, my current page is still showed and under it show the page of the link. What am I doing wrong?.
Next my routes.js code:
import Inicio from './componentes/Inicio.svelte'
import Login from './componentes/Login.svelte'
import Registro from './componentes/Registro.svelte'
import Nosotros from './componentes/Nosotros.svelte'
import Blog from './componentes/Blog1.svelte'
import ErrorRuta from './componentes/ErrorRuta.svelte'
const routes = {
'/':Inicio,
'/Login':Login,
'/Registro':Registro,
'/Nosotros':Nosotros,
'/Blog':Blog,
'*':ErrorRuta
}
export default routes
Next my App.svelte code:
<script>
import Router from 'svelte-spa-router'
import {link} from 'svelte-spa-router'
import routes from './routes'
</script>
<header class="site-header inicio">
<div class="contenedor contenido-header">
<div class="barra">
<a href="/" use:link>
<img class="cabecera" src="./img/Logo.jpg" alt="Logotipo">
</a>
<nav id="navegacion" class="navegacion">
<a href="/Login" use:link>Login</a>
<a href="/Registro" use:link>Registro</a>
<a href="/Nosotros" use:link>Nosotros</a>
<a href="/Blog" use:link>Blog</a>
</nav>
</div>
</div>
</header>
<main class="contenedor seccion">
<h2 class="font-weight300 centrar-texto">Servicios ofrecidos</h2>
<div class="contenedor-anuncios">
<div class="anuncio">
<img class="centrada" src="img/finanzas.jpg" alt="Imagen finanzas">
<div class="contenido-anuncio">
<h3 class="centrado">Robot EA ZigZag coberturas</h3>
<br/>
<p>Es importante contar con nociones básicas de trading y de MetaTrader 4 para operarlo. El robot EA ZigZag Coberturas se basa en el indicador ZigZag y cruce de medias para determinar la apertura de posiciones en el par de divisas en que se encuentre trabajando. Cuando la operación llega a un cierto nivel de Stop Loss, el robot activa coberturas y las administra, de tal forma que no haya pérdida, o la pérdida sea mínima.</p>
<br/>
<p>El objetivo del robot EA ZigZag coberturas, es proteger el capital, principalmente, de las variaciones drásticas y manipulaciones del mercado.</p>
<br/>
<p>Como todo robot, es imperativo que siempre se encuentre en línea y operando, para poder cumplir su propósito.</p>
Descargar
</div>
</div>
<div class="anuncio">
<img class="centrada" src="img/finanzas2.jpg" alt="Imagen finanzas2">
<div class="contenido-anuncio">
<h3 class="centrado">Servicios</h3>
<br/>
<p>Únete a nuestro canal de Telegram para compartir ideas de Trading.</p>
<br/>
<p>Participa en nuestro Blog para discutir estrategias que puedan ayudar a todos a alcanzar mejores resultados en el Trading.</p>
<br/>
<p>Participar no es gratis. El costo es que, de tus ganancias, destines un porcentaje (que tu decidas) a algún horfanato, asilo de ancianos (el que tu decidas).</p>
Ir al Blog
</div>
</div>
</div>
</main>
<Router {routes} />
<footer class="blue page-footer">
<div class="footer-copyright">
<div class="container">
© 2021 Copyright
</div>
</div>
</footer>
Problem solved.
App.svelte only should to have next code:
import Router from 'svelte-spa-router'
import routes from './routes'
<Router {routes} />
Related
I want to change my user personnal infos using axios. I created the form and the axios method. When i send the form i do have the status(201) but the data doesnt change ! But it does change if i do it on postman...
Here is my code !
<form class="modify-user-info">
<div>
<p>Changer de prénom</p>
<input type="text" v-model="user.firstname" placeholder="Changer de prénom" />
</div>
<div>
<p>Changer de nom de famille</p>
<input type="text" v-model="user.lastname" placeholder="Changer de nom de famille" />
</div>
<div>
<p>Changer d'adresse mail</p>
<input type="email" v-model="user.email" placeholder="Changer d'adresse mail" />
</div>
<div>
<p>Changer de mot de passe</p>
<input v-model="user.password" type="password" placeholder="Changer de mot de passe" />
</div>
<br />
</form>
updateUser() {
const formData = new FormData();
formData.append("firstname", this.user.firstname);
formData.append("lastname", this.user.lastname);
formData.append("email", this.user.email);
formData.append("password", this.user.password);
axios
.put("http://127.0.0.1:3000/api/auth/", formData,
{
headers: {
Authorization: "Bearer " + localStorage.getItem("token"),
},
})
.then((formData) => {
console.log(formData)
this.user.firstname = "";
this.user.lastname = "";
this.user.email = "";
this.user.password = "";
})
.catch((error) => console.log(error));
},
Thanks for the help !!!
Figured out by myself.
i stored the userId, firstname and lastname in the localStorage on login then i did
formData.append('firstname', localStorage.getItem("firstname"));
formData.append('lastname', localStorage.getItem("lastname"));
formData.append('userId', localStorage.getItem("userId"));
dont know if its the right way to do it but it works so...
I added Vue Stripe on my vue2 Project and I have 2 similar errors on my code :
Property 'redirectToCheckout' does not exist on type 'Vue | Element | (Vue | Element)[]'.
Property 'publishableKey' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'.
I followed the documentation on their website and everything is similar as their code so I don't know why I have those errors.
Screenshots
Here is my code if you want to check
<template >
<div class="section form-degustation-section" style="padding-top:150px">
<div class="mycontain form-degustation-contain" >
retrouner aux calendrier des soirées
<div class="soiree-text-presentation-contain">
<h1>{{ degustation[0].title }}</h1>
<p>{{ degustation[0].description }}</p>
</div>
<div class="soiree-form-contain">
<h2>Formulaire de réservation</h2>
<div class="w-form">
<div id="wf-form-soirees-degustation" name="wf-form-soirees-degustation" data-name="soirees degustation" action="https://natureetvins.foxycart.com/cart" method="post">
<label for="name">Nom et prénom</label>
<input type="text" class="w-input" maxlength="256" name="name" data-name="Name" placeholder="Ecrivez votre nom et prénom" id="name" data-kwimpalastatus="alive" data-kwimpalaid="1626170679038-0">
<label for="email">Email Address</label>
<input type="email" class="w-input" maxlength="256" name="email" data-name="Email" placeholder="Ecrivez votre adresse email" id="email" required="" data-kwimpalastatus="alive" data-kwimpalaid="1626170679038-1">
<label for="email-2">Téléphone</label>
<input type="text" class="w-input" maxlength="256" name="field" data-name="Field" placeholder="Ecrivez votre numéro de téléphone" id="field" required="" data-kwimpalastatus="alive" data-kwimpalaid="1626170679038-2">
<label for="quantity" >Quantité</label>
<input v-model="lineItems[0].quantity" type="number" class="w-input" maxlength="256" placeholder="Combien de places voulez vous acheter ?" required="">
<div class="w-embed">
<input type="hidden" name="name" value="Name">
<input type="hidden" name="prix" value="Prix">
<input type="hidden" name="image" value="Image">
</div>
<div class="event-cta-contain">
<div>
<stripe-checkout
ref="checkoutRef"
mode="payment"
:pk="publishableKey"
:line-items="lineItems"
:success-url="successURL"
:cancel-url="cancelURL"
/>
<button #click="submit()" class="cta-button w-button">Payer</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import { StripeCheckout } from "#vue-stripe/vue-stripe";
import axios from "axios";
import Vue from 'vue';
export default Vue.extend({
components: {
StripeCheckout,
},
data() {
this.publishableKey = "pk_test_51JAWNYJ3Er0D2qeQ9y9P0RXOsZPfxGC9VVour44gRX2NNiP2CBAzV0NECWsupE5WZhybNBT8TX5TDG5XUOHxg8rg00rMplGIhK";
return {
degustation: [{
}],
id_product: this.$route.params.id as string,
loading: false,
lineItems:[
{
price: "price_1JChqzJ3Er0D2qeQ8cZhp2RM",
quantity: 1 ,
}],
successURL: "http://google.fr",
cancelURL: "http://google.fr",
};
},
mounted() {
axios
.get(`http://localhost:3000/api/v1/degustations/${this.id_product}`)
.then((response) => (this.degustation = response.data));
},
methods: {
submit() {
this.$refs.checkoutRef.redirectToCheckout()
},
},
});
</script>
Do I need to import something else or ?
A couple of things are happening here.
First, keep in mind that if you want to access the publishableKey in the template then you should add it in the object that you're returning in the data() function.
Try to do some checking before accessing checkoutRef, try this:
if (this.$refs.checkoutRef) {
this.$refs.checkoutRef.redirectToCheckout()
}
I'm trying to make this code work. It should work, since this was given to me by my teacher, however, it doesn't and I'm not sure why. It seems that, even though I seem to have the condition correct, it won't perform the actions under the condition for the "NO LO SE" value. Thanks in advance!
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<!-- Reglas paises, las modificaremos con LEARN -->
<category>
<pattern>Cual es la capital de <set>pais</set></pattern>
<template>La capital de <star/> es <map name="capital"><star/></map>.</template>
</category>
<category>
<pattern>Cual es la capital de *</pattern>
<template>No lo se</template>
</category>
<!-- Regla 17 de aprendizaje -->
<category>
<pattern>la capital de * es *</pattern>
<template>
<think>
<set var="cap"><srai>CUAL ES LA CAPITAL DE <star/></srai></set>
</think>
<condition var="cap">
<li value="NO LO SE">
<learn>
<category>
<pattern>CUAL ES LA CAPITAL DE <eval><star/></eval></pattern>
<template>
La capital de <eval><star/></eval> es <eval><star index="2"/></eval>
</template>
</category>
</learn>
Recordare que la capital de <star/> es <star index="2"/>
</li>
<li>
Ya lo sabia.
</li>
</condition>
</template>
</category>
<!-- Fin paises -->
</aiml>
I use laravel and my project has a back part and a front on the back side all works but on the front side I find it difficult to make information accessible with this functionality. my controller is as follows:
public function show(AskQuestion $ask_questions, Respone $respone)
{
$ask_questions = AskQuestion::with(['email', 'objet_question', 'text_question', 'respone'])
->whereId($ask_questions)
->first();
//$ask_questions->timestamps = false;
//$ask_questions->views_count++;
//$ask_questions->save();
return view('askQuestions.show', compact('ask_questions'));
}
here my layoutcomposer.php
public function compose(View $view)
{
/*bind the asked question to view*/
$view->with('latestQuestions', AskQuestion::orderBy('id', 'desc')->take(10)->get());
/*binding the response to the view*/
$view->with('latestRespones', Respone::orderBy('id', 'desc')->take(10)->get());
/************/
$view->with('popularArticles', Article::orderBy('views_count', 'desc')->take(6)->get());
$view->with('latestArticles', Article::orderBy('id', 'desc')->take(6)->get());
$view->with('popularTags', Tag::withCount('articles')->orderBy('articles_count', 'desc')->take(20)->get());
$view->with('footerCategories', Category::take(6)->get());
}
here my show.blade.php
<div class="card">
<div class="card-header alert alert-primary">
{{-- $ask_questions->id --}}
</div>
<div class="card-body">
<hr>
<marquee>
<strong><p>Veuillez noter votre degré de satisfaction une fois que vous aurez la réponse à votre question svp!</p></strong>
</marquee>
<p> </p>
<div class="fat-content-small padding-left-10">
<ul>
#foreach ($ask_questions as $ask_question)
<li>
<a href="{{ route('askQuestions.show', [$ask_question->id, $ask_question->email, $ask_question->text_question]) }}">
<i class="fa fa-file-text-o"></i> {{ $ask_question->objet_question }}
</a>
</li>
#endforeach
</ul>
</div>
And with all these bugs I had to use a view compose but nothing bugs persist there I do not know what to do I really need help please
I have this HTML, and I'm trying scrape the values behind data-v-88f004c6 after "Compra:" and after "Venta:"
<div class="info-tc" data-v-88f004c6>
<span data-v-88f004c6>Tipo de cambio del dólar hoy en Perú</span>
<span data-v-88f004c6>
<i aria-hidden="true" class="fa fa-info-circle i-help" data-v-88f004c6></i>
</span>
<span data-v-88f004c6>Compra:
<strong data-v-88f004c6></strong>
</span>
<span data-v-88f004c6>Venta:
<strong data-v-88f004c6></strong>
</span>
</div>
When I bring up the developer tools from Chrome I can see that the values appear like this (3.199 and 3.237):
<div class="info-tc" data-v-88f004c6="">
<span data-v-88f004c6="">Tipo de cambio del dólar hoy en Perú</span>
<span data-v-88f004c6="">
<i aria-hidden="true" class="fa fa-info-circle i-help" data-v-88f004c6=""></i>
</span>
<span data-v-88f004c6="">Compra:
<strong data-v-88f004c6="">3.199</strong>
</span>
<span data-v-88f004c6="">Venta:
<strong data-v-88f004c6="">3.237</strong>
</span>
</div>
However when I scrape the values using Excel I get symbols like this for the prices.
Tipo de cambio del dólar hoy en Perú    Compra:   Venta:Â
I'm using a code like this to scrape the web:
Set GetRawHTML = New HTMLDocument
With CreateObject("WINHTTP.WinHTTPRequest.5.1")
.Open "GET", urlWebSite, False
.send
GetRawHTML = .responseText
End With
kambistafx = GetRawHTML.body.innerHTML
fxprice = kambistafx .getElementsByClassName("info-tc").Item(0).innerText
What should I do to scrape those values?
I did this with selenium basic
CSS selectors
#__layout span:nth-child(2) +*") 'compra
#__layout span:nth-child(3) +*") 'venta
These are contracted versions of full selectors which were:
#__layout > div > main > section.banner > div.central-section > div.col.paddingTop2 > section > div > span:nth-child(2) > strong
#__layout > div > main > section.banner > div.central-section > div.col.paddingTop2 > section > div > span:nth-child(3) > strong
Example CSS query:
Source page values
Code:
Option Explicit
Public Sub GetInfoSel()
Dim d As WebDriver, keys As New keys
Set d = New ChromeDriver
Const URL = "https://kambista.com/"
With d
.Start "Chrome"
.Get URL
Debug.Print .FindElementByCss("#__layout span:nth-child(2) +*").Text 'compra
Debug.Print .FindElementByCss("#__layout span:nth-child(3) +*").Text 'venta
.Quit
End With
End Sub
Note:
After installing Selenium basic and opening excel you need to add a reference via VBE > Tools > References > Selenium type library