投稿時間:2023-04-12 06:18:32 RSSフィード2023-04-12 06:00 分まとめ(26件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWS Machine Learning Blog Detect real and live users and deter bad actors using Amazon Rekognition Face Liveness https://aws.amazon.com/blogs/machine-learning/detect-real-and-live-users-and-deter-bad-actors-using-amazon-rekognition-face-liveness/ Detect real and live users and deter bad actors using Amazon Rekognition Face LivenessFinancial services the gig economy telco healthcare social networking and other customers use face verification during online onboarding step up authentication age based access restriction and bot detection These customers verify user identity by matching the user s face in a selfie captured by a device camera with a government issued identity card photo or preestablished profile photo They … 2023-04-11 20:31:28
海外TECH MakeUseOf How to Revoke Third-Party App Permissions for Apple Music https://www.makeuseof.com/revoke-third-party-app-permissions-apple-music/ apple 2023-04-11 20:45:17
海外TECH MakeUseOf How to Retouch a Model Using Camera Raw, Then Create a Preset https://www.makeuseof.com/model-retouching-in-camera-raw/ pictures 2023-04-11 20:30:16
海外TECH MakeUseOf The 10 Best Flowcharting Apps for Visualizing Your Workflows https://www.makeuseof.com/best-flowcharting-apps/ visualizing 2023-04-11 20:16:17
海外TECH DEV Community The Joy of Sharing: Why Developers Should Geek Out More https://dev.to/louiseann93/the-joy-of-sharing-why-developers-should-geek-out-more-1568 The Joy of Sharing Why Developers Should Geek Out More Hi I m Lou I ve been coding for a while now creating an assortment of projects from animations to landing pages games and responsive design As a developer one of the things that excites me the most is the satisfaction of creating something new and exciting However one of the more mentally challenging things that I face is the lack of enthusiasm from others when I share my projects or just want to geek out about something coding related While I can talk about these things with my colleagues friends and family most of the time I m returned with blank stares as they either don t quite understand or simply don t care It s not seeking validation from others but more wanting to share the passion and excitement I feel I think that it s great to celebrate our accomplishments ourselves but also when you see something so slick that you or someone else has made or you ve seen online and it makes you go then you look around and there s no one you can show it to Do you remember as a child the thrill of bringing home a handmade project and showing it off to your parents The same feeling of joy still exists in me today when I build something new and exciting By celebrating our accomplishments and sharing our passion with others we can inspire and motivate each other to keep pushing ourselves to new heights and let s not forget to celebrate our hard work and success along the way In conclusion being a developer is challenging but by focusing on the joy of creating and sharing our passion with others we can overcome the challenges and continue to grow and learn in our field What have you built or learnt recently that you ve been excited to talk about 2023-04-11 20:48:59
海外TECH DEV Community How Did You Get Started with COBOL? https://dev.to/devteam/how-did-you-get-started-with-cobol-3b3i How Did You Get Started with COBOL What drew you to COBOL Do you use the language on an everyday basis The purpose of this discussion thread is to encourage those who use COBOL to share their experiences 2023-04-11 20:35:07
海外TECH DEV Community Vue.js for Beginners #2 https://dev.to/ericnanhu/vuejs-for-beginners-2-766 Vue js for Beginners Previously we talked about some basic concepts in Vue and in this article we are going to dig deeper into this JavaScript framework and discuss event handling data options and components Event handlingFrom our course on JavaScript basics we learned that event handling is the most important concept in frontend development and Vue js being a JavaScript frontend framework must have the same concept built in In this article we are going to focus on two aspects event handling with the directive v on and form input handling with the directive v model And before we could start talking about the script section of Vue js we are going to quickly go through style bindings and class bindings An event is a user input it could be a keyboard input or a mouse click the user would usually expect some kind of response after the event takes place The event handler listens to that event and it would perform some actions in the background and return something as the response If you are not familiar with what an event is there is a detailed explanation here JavaScript BasicsThe v on directive which we can shorten to just the symbol is used to listen to events in Vue js We can use it to specify what kind of event we are listening to and what kind of action we are going to take after this event has been received lt div v on click someAction gt lt div gt lt div click someAction gt lt div gt That someAction could be a simple JavaScript expression or a very complicated method which allows us to build more complex logic lt div v on click count count gt lt div gt lt div v on click someMethod gt lt div gt Sometimes the method requires up to pass some extra arguments lt script gt export default methods add num this count this count num lt script gt lt template gt lt p gt count count lt p gt lt button v on click add gt Add lt button gt lt button v on click add gt Add lt button gt lt button v on click add gt Add lt button gt lt button v on click add gt Add lt button gt lt template gt It is also possible for one event to trigger multiple event handlers and the handlers are separated using a comma For example this time when a button is clicked the browser will pop out an alert box as well as re render the webpage lt script gt export default data methods say var msg count this count alert msg lt script gt lt template gt lt p gt count count lt p gt lt button v on click add say gt Add lt button gt lt template gt ModifiersModifiers are used to pass along extra details about the event For example we can use the once modifier to tell Vue that this event will only be triggered once lt template gt lt p gt count count lt p gt lt button v on click once add gt Add lt button gt lt template gt This time the Add button will only work once There are some other modifiers such as prevent which stops the default action of an event Or stop which stops the event propagation If you don t know what they are please read the article on Event Handling in the JavaScript course lt the click event s propagation will be stopped gt lt a click stop doThis gt lt a gt lt the submit event will no longer reload the page gt lt form submit prevent onSubmit gt lt form gt lt modifiers can be chained gt lt a click stop prevent doThat gt lt a gt There is also a different type of modifier which makes the event handler listen to events from a specific key or a mouse button or any of the combinations lt template gt lt Right Click gt lt div v on click right doSomething gt Do something lt div gt lt Control Click gt lt div v on click ctrl doSomething gt Do something lt div gt lt Enter Key gt lt div v on keyup enter doSomething gt Do something lt div gt lt Alt Enter gt lt div v on keyup alt enter doSomething gt Do something lt div gt lt template gt Form input bindingThe form is a very important component in web development it provides a portal for the user to communicate with the backend However we know from our course on HTML Forms that forms could have a lot of different types of inputs and each of them is associated with a different data type It would be a pain in the neck if we try to process all those data types one by one Luckily with Vue js we can use one single directive v model to bind all the input data regardless of their data types For instance here we have a standard text input lt input v model message gt lt p gt Message is message lt p gt Here the user input has the type string and it will be bound to the variable massage Multiline text input works exactly the same lt textarea v model message gt lt textarea gt lt p gt Message is message lt p gt Checkbox lt script gt export default data return checked false lt script gt lt template gt lt input type checkbox v model checked gt lt p v if checked gt The box is checked lt p gt lt p v else gt The box is NOT checked lt p gt lt template gt As for the checkbox the user input is a Boolean value either true or false In this example the user input is bound to the variable checked and the directive v if will be used to check the truthiness of checked However sometimes in a form there are multiple checkboxes which means having only two values true or false would not be enough In this case we ll need to add a value attribute to each of the checkboxes lt script gt export default data return checkedBoxes lt script gt lt template gt lt div id v model multiple checkboxes gt lt input type checkbox id one value one v model checkedBoxes gt lt label for one gt one lt label gt lt input type checkbox id two value two v model checkedBoxes gt lt label for two gt two lt label gt lt input type checkbox id mike value three v model checkedBoxes gt lt label for three gt three lt label gt lt br gt lt span gt Checked boxes checkedBoxes lt span gt lt div gt lt template gt Notice this time the variable checkedBoxes is bound to an array and when a box is checked its value whatever you assigned to its value attribute will be appended to that array RadioRadio is kind of like a multi checkboxes group except you can only pick one option So in this case the user input will always be a single string lt div id v model radiobutton gt lt input type radio id one value One v model picked gt lt label for one gt One lt label gt lt br gt lt input type radio id two value Two v model picked gt lt label for two gt Two lt label gt lt br gt lt span gt Picked picked lt span gt lt div gt The variable picked will be a string instead of an array SelectFor a single select the variable is a string type lt script gt export default data return selected lt script gt lt template gt lt select v model selected gt lt option disabled value gt Please select one lt option gt lt If you assign a value attribute that value will be assigned to the variable selected gt lt option value aaaaaaa gt A lt option gt lt If you do not assign a value attribute whatever is inside the lt option gt element will be assigned to the variable selected gt lt option gt B lt option gt lt option gt C lt option gt lt select gt lt span gt Selected selected lt span gt lt template gt lt style gt lt style gt For a muliselect the variable will be bound to an array lt script gt export default data return selected lt script gt lt template gt lt select v model selected multiple gt lt option gt A lt option gt lt option gt B lt option gt lt option gt C lt option gt lt select gt lt span gt Selected selected lt span gt lt template gt Style binding Class bindingFrom our course on CSS Basics we know that class is how we can assign the same CSS code to different HTML elements and by changing the class name we can easily change the CSS code associated with that element We can change the class name of an HTML element dynamically in Vue js like this lt div v bind class active isActive gt lt div gt In this example active is a class name and isActive is a variable with a Boolean value If isActive is true then the class name active will be rendered We can have multiple class names in here lt div v bind class class one isClassOneActive class two isClassTwoActive gt lt div gt CSS bindingWe can also bind CSS codes directly like this lt script gt export default data return activeColor red fontSize lt script gt lt template gt lt div v bind style color activeColor fontSize fontSize px gt lt div gt lt template gt Although it is usually better to put the object inside the data method so that our template section looks cleaner lt script gt export default data return styleObject color red fontSize px lt script gt lt template gt lt div v bind style styleObject gt lt div gt lt template gt Now it is finally time for us to dive into the most important part of this course the script section of a Vue application To master a web framework the most important step is to understand how data could circulate inside your project and how different types of data are treated differently That would be the focus of this article In this article we are going to talk about several different types of data options Do not confuse data options with the data method we talked about before The data method is a method where we declare a list of variables that we are going to use in the component instance and data options is a collection of properties and methods that deals with data in Vue js which includes the data method After that we are going to discuss the lifecycle hooks which are interfaces that allow us to inject codes at different stages of a component instance s creation Data options dataFirst of all the data method Like we ve seen over and over again it is a method that returns an object and inside that object we define all the variables we need for this component instance Vue js will automatically wrap these variables inside its reactivity system meaning that when the value of the variable changes the webpage automatically rerenders to reflect the changes The variables are only added as the instance was being created You can in fact assign variables after the instance has already been created but that variable will not be a part of the reactivity system So you should always create them inside the data method if there isn t an initial value you can use a placeholder value such as null or undefined lt script gt export default data return count name lt script gt methodsThe methods is another data option we are already familiar with It is the place where we define all the logic for our application When you create a method Vue js will automatically bind the this keyword to that method So to access the value of a variable for the current instance you need to use this variableName lt script gt export default data return count methods add num this count this count num lt script gt lt template gt lt p gt count count lt p gt lt button click add gt Add lt button gt lt template gt computedThe computed property is very similar to the methods property It is also a place for us to store methods that deal with data However computed is usually for getters and setters The getters are methods that return the value of a variable and setters are methods that assign a new value for a variable lt script gt export default computed This is a getter showCount return this count This is a setter resetCount this count lt script gt lt template gt lt p gt count showCount lt p gt lt button click add gt Add lt button gt lt button click resetCount gt Reset lt button gt lt template gt It seems like we could have done this with methods so why does Vue have both methods and computed and what exactly is their difference The two approaches here indeed produce the same result their difference however is that the computed is cached while the methods is not When a computed method is invoked the computations will perform once and the result will be stored in the cache The method will not reevaluate as long as the variables that it depends on have not changed While in the case of methods every time a re render happens it will perform the computation all over again Using computed can save you a lot of trouble if you are dealing with a large amount of data that would be very expensive to compute over and over again watchThe watch property defines methods that will run whenever a variable changes its value It essentially provides us with a way to customize our own reactivity system lt script gt export default data return count methods add num this count this count num watch count newCount oldCount let diff newCount oldCount console log diff diff lt script gt lt template gt lt p gt count count lt p gt lt button click add gt Add lt button gt lt button click add gt Add lt button gt lt button click add gt Add lt button gt lt button click add gt Add lt button gt lt template gt lt style gt lt style gt In this example whenever the value of count changes the page will not only re render it will also output a message in the console telling you the difference between the old value and the new value Rember that the name of the method and the name of the variable must match That s not all in fact there are three other data option props emit and expose However to understand these data options we need to first dig deeper into the component system of Vue js We ll talk about them in the next article Lifecycle hooksLifecycle HooksDetailsbeforeCreateCalled immediately after the component instance has been initialized This is before the data and the event listener has been setup You cannot access them at this stage createdThis is after the component has been created and the data options has been processed However the mounting has not started which means the component hasn t yet appeared on the webpage beforeMountRight before the mounting starts mountedCalled after the mounting has finished This does not guarantee that all child components has been rendered beforeUpdateAfter the data has changed but before the DOM structure change This would be a good place to access the existing DOM before any changes happen updatedCalled after the DOM has been re rendered It is usually better to use watchers to react to data change instead In the final part of the course we are going to investigate the component system of Vue js Here is an example of a component components ComponentOne vue lt script gt export default lt script gt lt template gt lt p gt This is the component ComponentOne vue lt p gt lt template gt We can use this component inside our App vue file lt script gt import the componentimport ComponentOne from components ComponentOne vue export default Declare the imported component components ComponentOne lt script gt lt template gt lt p gt This is the root component App vue lt p gt lt Use the component here gt lt ComponentOne gt lt ComponentOne gt lt template gt Components are reusable we can create multiple instances of the same component on one page And they are all independent of each other if the state of one instance changes it will not affect the others components ComponentOne vue lt script gt export default data return count methods add num this count num lt script gt lt template gt lt p gt This is the component ComponentOne vue lt p gt lt p gt count count lt p gt lt button click add gt Add lt button gt lt template gt App vue lt template gt lt p gt This is the root component App vue lt p gt lt Use the multiple component instances gt lt ComponentOne gt lt ComponentOne gt lt ComponentOne gt lt ComponentOne gt lt template gt We can also import a component inside another component forming a nested structure components ComponentOne vue lt script gt import ComponentTwo from ComponentTwo vue export default components ComponentTwo lt script gt lt template gt lt p gt This is the component ComponentOne vue lt p gt lt Import another component gt lt ComponentTwo gt lt ComponentTwo gt lt template gt components ComponentTwo vue lt script gt export default lt script gt lt template gt lt p gt This is the component of a component ComponentTwo vue lt p gt lt template gt Organizing componentsIn fact it is very common for a real life application to have a nested structure like this For example here we are trying to build a frontend for a blog and we need a list of recent articles In real life applications the data is usually stored inside a database and we have a backend that will retrieve the correct information and send it to the frontend For now we ll just assume we have a fully functional backend and the data has already been sent to us App vue lt script gt import PostListComponent from components PostListComponent vue export default components PostListComponent lt script gt lt template gt lt PostListComponent gt lt PostListComponent gt lt template gt components PostListComponent vue lt script gt import PostComponent from PostComponent vue export default data return posts id title Article id title Article components PostComponent lt script gt lt template gt lt h gt This is a list of recent articles lt h gt lt PostComponent v for post in posts gt lt PostComponent gt lt template gt components PostComponent vue lt script gt export default lt script gt lt template gt lt h gt This is the title lt h gt lt template gt As you can see we only have one PostComponent vue and it is reused multiple times using a v for loop This will save us a lot of trouble since we don t have to rewrite the same code over and over again Passing data to childNow we face a new problem we know that by default component instances are isolated from each other the data change in one instance does not affect others since we cannot access the data in another instance However what if we need that to happen For instance in our previous example in the place where it should be the title of the article we had to use a placeholder text instead because the data about the post are in the parent component PostListComponent vue and we cannot access them in the child component PostComponent vue We need to somehow pass the data from the parent to the child That can be achieved using the props option components PostListComponent vue lt template gt lt h gt This is a list of recent articles lt h gt lt PostComponent v for post in posts v bind title post title gt lt PostComponent gt lt template gt components PostComponent vue lt script gt export default props title lt script gt lt template gt lt h gt title lt h gt lt template gt Let s take a closer look at how data flows in this example First we bind the title of the post to the variable title and pass that variable to the PostComponent The PostComponent receives the variable title with props property and then uses it in the template It is also possible for us to validate the transferred data in the child component using the object syntax instead of an array components PostComponent vue lt script gt export default props type check height Number type check plus other validations age type Number default required true validator value gt return value gt lt script gt However it doesn t matter which syntax you are using this data flow is one way only It is always from the parent to the child if the parent changes the child changes but not the other way around You should not try to update a props in a child component Instead the best practice is to declare a new variable in the child and use the transferred props as its initial value components PostComponent vue lt script gt export default props title data return articleTitle this title lt script gt Passing event to parentWhen we are building a web application sometimes it is necessary to communicate from the child component to the parent component For example let s go back to our post list example this time we add a button in the PostComponent and every time the user clicks on the button it enlarges the font for the entire page To do this it would require us to transfer the click event which happens in the child component to the parent component and when the parent component catches that event it would change the value of the corresponding variable the variable that stores the size of the font This can be done using the emits property components PostComponent vue lt script gt export default props title Declare the emited events emits enlargeText lt script gt lt template gt lt h gt title lt h gt lt When the button is clicked it emits a event called enlargeText to the parent gt lt button v on click emit enlargeText gt Enlarge Text lt button gt lt template gt lt style gt lt style gt components PostListComponent vue lt script gt import PostComponent from PostComponent vue export default data return posts id title Article id title Article id title Article id title Article Set font size titleFontSize components PostComponent lt script gt lt template gt lt Dymanically bind the CSS style gt lt div v bind style fontSize titleFontSize em gt lt listen to the event enlargeText emited from the child component gt lt PostComponent v for post in posts v bind title post title v on enlargeText titleFontSize gt lt PostComponent gt lt div gt lt template gt lt style gt lt style gt The event starts from the child component when the button is clicked it emits an event called enlargeText using a built in function emit and that event is declared in the script section using the emits property And when the event gets caught by the parent component the parent changes the value of the variable titleFontSize Now what if we want to try something more complex What if we want to specify font size using a text box instead of just a button This would require us to transfer some data to the parent along with the event components PostComponent vue lt script gt export default props title Declear the emited events emits changeFontSize lt script gt lt template gt lt h gt title lt h gt lt The attribute value binds with the user input its initisl value is event target value contains the current value of value gt lt input type text v bind value v on change emit changeFontSize event target value gt lt template gt components PostListComponent vue lt script gt import PostComponent from PostComponent vue export default data return posts id title Article titleFontSize components PostComponent lt script gt lt template gt lt div v bind style fontSize titleFontSize em gt lt listen to the event changeFontSize emited from the child component and the variable event contains the data that is transferred with the event gt lt PostComponent v for post in posts v bind title post title v on changeFontSize titleFontSize event gt lt PostComponent gt lt div gt lt template gt If you liked this article please also check out my other tutorials Django for BeginnersLaravel for BeginnersCreate a Modern Application with Django and VueBeginner s Roadmap to Web Development 2023-04-11 20:11:32
海外TECH DEV Community Criando um algoritmo de pesquisa em largura em grafos https://dev.to/antiduhring/criando-um-algoritmo-de-pesquisa-em-largura-em-grafos-3af3 Criando um algoritmo de pesquisa em largura em grafosGrafos são estruturas de dados que consistem em vértices ou nós conectados por arestas ou arcos Eles são amplamente utilizados em várias áreas como ciência da computação matemática física biologia entre outras Na ciência da computação por exemplo os grafos são usados para representar relações entre objetos como usuários em uma rede social ou para modelar rotas e caminhos em mapas como as ruas no Google Maps Eles permitem a análise de dados complexos possibilitando a descoberta de padrões e informações úteis Vejamos o seguinte grafo Para responder perguntas como existe um caminho do vértice A ao vértice B ou qual éo caminho mínimo do vértice A ao vértice B uma das soluções éutilizar o algoritmo de pesquisa em largura BFS breadth first search Ele começa no vértice A e expande sua pesquisa para os vértices conectados a ele que são B e C Em seguida avança para os vértices conectados a B e C e assim por diante buscando em largura Vamos criar um exemplo de algoritmo de pesquisa em largura usando JavaScript para responder a seguinte questão Qual o caminho mais curto do vértice A ao vértice F Primeiro vamos definir as vértices e suas conexões como um objeto const connections A B C B A D F C A D E D B C F B E E C F Estamos dizendo que A se conecta com B e C que B se conecta com A D e F e assim sucessivamente Agora vamos começar a criar nosso algoritmo Primeiro precisamos que ele faça um loop por todos os vértices do grafo e identifique quais jáforam visitados function findShortestPath graph startNode endNode fila dos vertices que serão visitados const queue startNode objeto contendo os vértices que jáforam visitados const visited startNode true objeto que vai identificar quais os vértices anteriores a um determinado vértice pra montarmos o caminho const predecessor Loop enquanto houverem vértices para ser visitados while queue length Obtém e remove o primeiro vértice da lista const currNode queue shift RESTO DO NOSSO ALGORITMO return null Agora precisamos fazer com que a cada novo vértice buscado a função obtenha o vértice anterior que se ligue a ele e adicione o caminho no nosso objeto predecessor function findShortestPath graph startNode endNode const queue startNode const visited startNode true const predecessor while queue length const currNode queue shift Obtém os vértices que estão conectados ao vértice atual aqui são chamados de vizinhos const neighbors graph currNode Itera sobre cada vértice vizinho for const neighbor of neighbors Apenas continua a busca se ele ainda não tiver sido visitado if visited neighbor visited neighbor true Adiciona no objeto predecessor o vértice que estáligado a ele predecessor neighbor currNode Adiciona ele mesmo na fila de vértices para serem pesquisados queue push neighbor RESTO DO NOSSO ALGORITMO Agora que o algoritmo jábusca todos os vértices do nosso grafo precisamos fazer com que ele obtenha o vértice de destino e a partir do objeto predecessor construa o caminho de volta ao ponto inicial function findShortestPath graph startNode endNode const queue startNode const visited startNode true const predecessor while queue length const currNode queue shift const neighbors graph currNode for const neighbor of neighbors if visited neighbor visited neighbor true predecessor neighbor currNode queue push neighbor Observa se o vizinho que estásendo checado atualmente éo nosso destino if neighbor endNode Começa a reconstruir o caminho mais curto a partir do vértice de chegada const shortestPath endNode Obtém o vértice atual de onde os vizinhos foram obtidos let prevNode currNode Loop enquanto o caminho ainda não tiver sido reconstruído atéo ponto de partida while prevNode startNode Adiciona no começo da array shortestPath o vértice prevNode shortestPath unshift prevNode Obtém o predecessor do prevNode e faz dele o prevNode atual prevNode predecessor prevNode shortestPath unshift startNode return shortestPath return null Ao executar o nosso código vemos o resultado da busca const connections A B C B A D F C A D E D B C F B E E C F const shortestPath findShortestPath connections A F console log shortestPath A B F Podemos ver que o caminho mais curto do vértice ao vértice F de fato éA gt B gt F O algoritmo de busca em largura éuma ferramenta essencial na resolução de problemas que envolvem a descoberta do menor caminho entre dois pontos em um grafo Mas éimportante lembrar que cada aplicação pode ter suas particularidades e o algoritmo de pesquisa em largura não éo único e pode não ser o melhor algoritmo de busca pelo menor caminho em muitos casos Saber implementar um algoritmo de pesquisa em largura pode ajudar a solucionar problemas complexos em diversas áreas como redes de transporte otimização de rotas e atémesmo jogos 2023-04-11 20:08:54
海外TECH DEV Community Vue.js for Beginners #1 https://dev.to/ericnanhu/vuejs-for-beginners-1-4ilc Vue js for Beginners Vue is a frontend JavaScript framework that helps us quickly create user interfaces It is more lightweight and beginner friendly compared to other frameworks such as React or Angular The core library of Vue focuses on the view layer only which is the part that the users can see That is also why the author named the framework Vue pronounced as view InstallationTo create a new Vue application go to the terminal and run the following command npm init vue latestThis command will prompt you with multiple options such as TypeScript Vue Router and Pinia For this tutorial we don t need any of these features but you can play around with them if you want Project name … lt your project name gt Add TypeScript …No YesAdd JSX Support …No YesAdd Vue Router for Single Page Application development …No YesAdd Pinia for state management …No YesAdd Vitest for Unit testing …No YesAdd Cypress for both Unit and End to End testing …No YesAdd ESLint for code quality …No YesAdd Prettier for code formatting …No YesScaffolding project in lt your project name gt Done Next go to the project folder install the necessary packages and run the development server cd lt your project name gt npm installnpm run devOpen your browser and go to http localhost you should see Vue s welcome page IntroductionBefore we start let s take a look at what has been installed into our project folder There are a few things we are already familiar with The node modules contains the packages we installed The public folder contains the files and resources that we wish to make public The package lock json and package json files are both for managing packages which we talked about before in the JavaScript Basics tutorial and the index html file is the start point of our project For this tutorial we ll only focus on the files inside the src directory The assets folder stores the images CSS files and other resources The main js file mounts and configures all the Vue apps in our project and it is also the script that we import into the index html file The App vue is the actual Vue app this is where we do most of the coding However sometimes the app gets too big it makes more sense if we divide the app into multiple components we ll store these components inside the components folder We ll take a closer look at what happens when you go to http localhost Let s start from index html and notice what we have inside the lt body gt tag lt body gt lt div id app gt lt div gt lt body gt The only line of the code that matters is lt div id app gt lt div gt Why Let s go to main js import createApp from vue import App from App vue createApp App mount app This file imports the Vue app and mounts that app to the HTML element with id app Recall that represents id and represents class This is why that lt div gt element is so important even though it is empty Next go to the App vue file lt script setup gt import HelloWorld from components HelloWorld vue lt script gt lt template gt lt img alt Vue logo src assets logo png gt lt HelloWorld msg Hello Vue Vite gt lt template gt lt style gt app font family Avenir Helvetica Arial sans serif lt style gt We immediately see that the file is divided into three sections The lt script gt section contains the JavaScript code the lt template gt contains HTML elements and lt style gt contains CSS codes Notice in the lt script gt section we imported a component from the components folder and used it in the lt template gt section And finally go to the HelloWorld component You can see that it has the exact same structure You can also try to edit something inside this file and see if the webpage changes BasicsNow let s go back to the App vue file and delete everything unnecessary so we ll have a clean and empty vue document lt script gt lt script gt lt template gt lt template gt lt style gt lt style gt Methods and propertiesAs you know the lt script gt section is where we write JavaScript code but since Vue is a framework there are a few restrictions and requirements This section usually has the following structure App vue lt script gt export default data return name value methods xxx lt script gt This means when you are importing this Vue app into main js you are actually importing a bunch of methods and properties Each property method serves a different purpose For example the data method returns an object containing all the variables that are used in the app Be careful that data must be a method and not just a property this is what makes Vue reactive meaning if the value of the variable changes the web pages changes without having to reload The methods property contains all the methods that are created by you the coder Of course there are other properties allowed such as props computed inject and setup We ll discuss them in detail in the future A simple counter appKnowing just these two simple concepts the data method and the methods property is enough for us to start creating apps For example we ll create an app that counts how many times a button has been clicked App vue lt script gt export default data return count lt script gt lt template gt lt button v on click count gt click me lt button gt lt p gt count count lt p gt lt template gt First we declare a variable count whose initial value is and in the lt template gt section we set up an event listener v on click each time the button is clicked count increments by The variable will then be rendered using double curly braces We ll talk about these syntaxes later What if we want another button that resets the value of count This is what we can do App vue lt script gt export default data return count methods clear this count lt script gt lt template gt lt button v on click count gt click me lt button gt lt button v on click clear gt clear lt button gt lt p gt count count lt p gt lt template gt Remember to use the keyword this when referring to variables that belong to this application instance The variable that we defined in the data method is unique to this instance meaning it cannot be accessed by other instances or components For example we can create another counter and import it into App vue as a component components Counter vue lt script gt export default data return count methods clear this count components Counter lt script gt lt template gt lt button v on click count gt click me lt button gt lt button v on click clear gt clear lt button gt lt p gt count count lt p gt lt template gt lt style gt lt style gt App vue lt script gt import Counter from components Counter vue export default data return count methods clear this count components Counter lt script gt lt template gt lt button v on click count gt click me lt button gt lt button v on click clear gt clear lt button gt lt p gt count count lt p gt lt Counter gt lt template gt lt style gt lt style gt Try this in your own browser and you will find that even though the variable we defined for Counter vue and App vue are both counter they do not seem to affect each other and when you reset the variable s value only the one in the same instance becomes LifecyclesFinally I d like to introduce another important concept in Vue it s called lifecycles When an app instance is been created it goes through a series of processes such as initializing data compiling the template mounting the template onto the DOM and updating the template as the data changes This allows us to divide the life of an application instance into several stages and Vue provides us with several lifecycle hooks that allow us to add our own code at different stages For example the function created allows us to add code that is supposed to run right after the instance has been created lt script gt export default data return count created console log initial count is this count lt script gt There are other lifecycle hooks that we could use Here is a diagram showing all of them and where they are in the lifecycle InterpolationsIn the first section of this article we learned that a Vue file is divided into three sections lt template gt lt script gt and lt style gt However we merely touched the surface of Vue js last time starting from now we are going to talk about the details of each of these sections and we ll start with the easiest the template section We know that the template section only contains HTML codes it shows what the Vue file will eventually be rendered into However it can t be that simple since we want the page to be reactive we want it to change as the data changes To do that we need to inform Vue js where to put the data TextText interpolation is the most basic form of data binding which uses double curly braces like this lt script gt export default data return msg This is a message lt script gt lt template gt lt p gt Message msg lt p gt lt template gt Try to change the value of msg and you ll see that the page changes without having to be refreshed Raw HTMLHowever what if we want the data to be more complex Say we want to bind a piece of HTML code to a variable see what happens when you try to output HTML with double curly braces lt script gt export default data return msg lt span style color red gt This is a message lt span gt lt script gt lt template gt lt p gt Message msg lt p gt lt template gt The data will be treated as plain text instead of HTML codes To solve this problem we need to tell Vue js that the data we are trying to render is HTML by using an HTML directive lt p gt Message lt span v html msg gt lt span gt lt p gt This time when the data is being rendered the original lt span gt tag will be replaced AttributesSometimes it might be useful if we bind an attribute to a variable For instance we want to enable a button when the user is verified and disable it when the user is not verified We can bind the disabled attribute to the verified variable by using the v bind directive lt script gt export default data return verified false lt script gt lt template gt lt button v bind disabled verified gt Button lt button gt lt template gt Remember that the exclamation mark inverts the value of varified JavaScript expressionsIt is also possible for us to use simple JavaScript expressions inside the template In fact the varified we just saw is a very simple example We can also do something more complicated like these number ok YES NO message split reverse join lt div v bind id list id gt lt div gt However there are some restrictions for example statements that declare new variables are not going to work Loops and flow controls if statements are not going to work either DirectivesIn Vue js directives are special attributes with the prefix v Their primary function is to bind a side effect to a DOM node For instance the following example binds a variable to the lt p gt element using the v if directive It works just like a regular if statement When verified is true the first lt p gt element will be rendered and when verified is false the second lt p gt element will be rendered lt p v if verified gt You are verified lt p gt lt p v if verified gt You are NOT verified lt p gt ArgumentsSome directives can take extra arguments For example the v bind directive which we ve already seen is used to bind an HTML attribute to a variable and it takes the name of that attribute as an argument lt p v bind color colorName gt lt p gt lt button v bind class className gt click me lt button gt Another example is the v on directive It is the event listener in Vue js lt a v on click action gt lt a gt When this link is clicked the function that is bonded to the variable action will be executed It is also possible to bind the argument itself to a variable For example lt a v on event action gt lt a gt In this case if var event click this example will be equivalent to v on click action In fact v bind and v on are the two most commonly used directives that is why Vue js has created special shortcuts for them The v bind can be shortened to just a colon and v on can be represented using just The following codes are equivalent lt a v bind href url gt lt a gt lt a href url gt lt a gt lt a v on click action gt lt a gt lt a click action gt lt a gt Flow ControlNext let s talk about the if statements in Vue Like we ve seen before the v if directive binds the element with a boolean value If the boolean value is true the element will be rendered and if it is false the element will simply be ignored by Vue Other than v if there is also a v else directive which works with the v if directive lt p v if verified gt You are verified lt p gt lt p v else gt You are NOT verified lt p gt What if you need more than just two conditions The v else if directive as the name suggests creates an else if block It can be chained multiple times hence creating multiple conditions lt p v if num gt The number is lt p gt lt p v else if num gt The number is lt p gt lt p v else if num gt The number is lt p gt lt p v else if num gt The number is lt p gt lt p v else gt The number is lt p gt LoopsFinally other than if statements Vue also allows us to create simple for loops inside the template Its syntax actually resembles the for loops in Python if you are familiar with the language We can render a list of items in an array like this lt script gt export default data return items num num num num num lt script gt lt template gt lt ul gt lt li v for item in items gt The number is item num lt li gt lt ul gt lt template gt Vue also supports an optional second argument for index number lt template gt lt ul gt lt li v for item index in items gt index The number is item num lt li gt lt ul gt lt template gt If you liked this article please also check out my other tutorials Django for BeginnersLaravel for BeginnersCreate a Modern Application with Django and VueBeginner s Roadmap to Web Development 2023-04-11 20:06:30
Apple AppleInsider - Frontpage News Get Apple's 1TB MacBook Pro 16-inch for $2,499 ($200 off), plus $60 off AppleCare https://appleinsider.com/articles/23/04/11/get-apples-1tb-macbook-pro-16-inch-for-2499-200-off-plus-60-off-applecare?utm_medium=rss Get Apple x s TB MacBook Pro inch for off plus off AppleCareDespite being released in early Apple s latest MacBook Pro inch is heavily discounted with the TB M Pro model now off in addition to off AppleCare Save on this TB MacBook Pro Looking for a great deal on Apple s current MacBook Pro inch with a core GPU GB of memory and TB of storage You re in luck as Apple Authorized Reseller Adorama is offering AppleInsider readers off the system itself and another off AppleCare Read more 2023-04-11 20:37:35
Apple AppleInsider - Frontpage News New AirPods Firmware update pulled after Apple error [u] https://appleinsider.com/articles/23/04/11/new-firmware-is-available-for-airpods-airpods-pro-airpods-max?utm_medium=rss New AirPods Firmware update pulled after Apple error u Apple briefly released a firmware update for AirPods AirPods Pro and AirPods Max but pulled the update soon after Apple updates AirPods firmwareDevices that could install the update include AirPods second and third generations the first and second generations of AirPods Pro and the AirPods Max The new version number was E up from B that Apple released in January Read more 2023-04-11 20:58:17
海外TECH Engadget Instagram creators' Artifact app is starting to look more like Reddit https://www.engadget.com/instagram-creators-artifact-app-is-starting-to-look-more-like-reddit-200546113.html?src=rss Instagram creators x Artifact app is starting to look more like RedditArtifact the news aggregation app from the creators of Instagram now has some social features following its latest update Users can now create profiles and comment on any article in the app Taking a cue from Reddit Artifact will let you upvote and downvote other users comments which will factor into commenters reputation scores and help to moderate discussions The app is also using artificial intelligence for moderation Artifact says the reputation score quot represents the earned trust from the community and will help you weigh people s opinions and help us filter out bad behavior quot The goal according to a blog post is to foster a positive community in which everyone feels encouraged to take part The app will let you know when your comments get upvotes or downvotes You ll also be notified when your contacts comment on things they read ArtifactYou ll need a profile which is optional to comment on articles Profiles can include your photo and bio adding both will apparently boost your reputation You ll need to provide a verified phone number to create one A phone number is also needed if you want to move to a different device and retain your Artifact history and preferences Instagram founders Kevin Systrom and Mike Krieger unveiled Artifact back in January It uses AI to curate news and present you with things it reckons you ll want to read quot We have a strong and growing community and sometimes the most important voices are never interviewed or quoted quot Systrom wrote in an Artifact comment quot These discussions give everyone a chance to participate and have a voice quot In a bit of a coincidence Artifact is gaining true social components on the same day that Substack is rolling out its Twitter esque Notes feature In a sense the two relative upstarts are trying to take on established social media platforms at their own game This article originally appeared on Engadget at 2023-04-11 20:05:46
海外TECH CodeProject Latest Articles TracerX Logger and Viewer for .NET https://www.codeproject.com/Articles/23424/TracerX-Logger-and-Viewer-for-NET-2 thread 2023-04-11 20:22:00
ニュース BBC News - Home Junior-doctors' strike: Cancer survivor's anguish over cancelled op https://www.bbc.co.uk/news/health-65241951?at_medium=RSS&at_campaign=KARANGA breast 2023-04-11 20:19:09
ニュース BBC News - Home Manchester City 3-0 Bayern Munich: Pep Guardiola's side take control in quarter-finals https://www.bbc.co.uk/sport/football/65233785?at_medium=RSS&at_campaign=KARANGA bayern 2023-04-11 20:52:06
ニュース BBC News - Home England 0-2 Australia: Lionesses' unbeaten run ends as Sam Kerr shines https://www.bbc.co.uk/sport/football/65232235?at_medium=RSS&at_campaign=KARANGA australia 2023-04-11 20:55:05
ビジネス ダイヤモンド・オンライン - 新着記事 東急不動産、あざみ野で「億ション売れ残り」続出!中古市場にも及ぶバブル崩壊の前兆 - 不動産デベ新序列 バブル崩壊前夜 https://diamond.jp/articles/-/320894 億ション 2023-04-12 05:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 バイデン氏、WSJ記者の両親に釈放への取り組み伝える - WSJ発 https://diamond.jp/articles/-/321149 釈放 2023-04-12 05:21:00
ビジネス ダイヤモンド・オンライン - 新着記事 グノーブル、希学園首都圏、エルカミノ…御三家合格率「SAPIX以上」の少数精鋭中学受験塾を大解剖 - 2024年入試対応!わが子が伸びる中高一貫校&塾&小学校 https://diamond.jp/articles/-/320486 2023-04-12 05:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 植田日銀「6月修正」の可能性残す、YCC撤廃時は1ドル=120円程度の円高に - 政策・マーケットラボ https://diamond.jp/articles/-/321081 長期金利 2023-04-12 05:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 関関同立を目指せるのに入りやすい「お得な中高一貫校」ランキング【2024入試版・82校】 - 2024年入試対応!わが子が伸びる中高一貫校&塾&小学校 https://diamond.jp/articles/-/320485 関関同立を目指せるのに入りやすい「お得な中高一貫校」ランキング【入試版・校】年入試対応わが子が伸びる中高一貫校塾小学校中学受験生を持つ親の多くが望む、最終的な「出口進学先」の大学名のボリュームゾーンは、関西ならば「関関同立」だろう。 2023-04-12 05:10:00
ビジネス ダイヤモンド・オンライン - 新着記事 【荒川区ベスト10】小学校区「教育環境力」ランキング!【偏差値チャート最新版】 - 東京・小学校区「教育環境力」ランキング2022 https://diamond.jp/articles/-/320603 【荒川区ベスト】小学校区「教育環境力」ランキング【偏差値チャート最新版】東京・小学校区「教育環境力」ランキング子どもにとってよりよい教育環境を目指し、入学前に引っ越して小学校区を選ぶ時代になった。 2023-04-12 05:05:00
ビジネス 不景気.com 今仙電機製作所が希望退職者募集で150名を削減、従業員約1割 - 不景気com https://www.fukeiki.com/2023/04/imasen-cut-150-job.html 今仙電機製作所 2023-04-11 20:09:28
ビジネス 東洋経済オンライン 医師が警告!「朝食を食べない人」が超危険な根拠 "血管の名医"が「簡単、時短、やせる朝食」も紹介 | 健康 | 東洋経済オンライン https://toyokeizai.net/articles/-/661335?utm_source=rss&utm_medium=http&utm_campaign=link_back 東洋経済オンライン 2023-04-12 05:40:00
ビジネス 東洋経済オンライン AIが人間の意思決定を操作する「本当の怖さ」 不透明な運営の「チャットGPT」に問われる責任 | インターネット | 東洋経済オンライン https://toyokeizai.net/articles/-/665769?utm_source=rss&utm_medium=http&utm_campaign=link_back 社会的不安 2023-04-12 05:20:00
ビジネス 東洋経済オンライン 最新版!「収入が多い国立大学法人」ランキング 「国際卓越研究大学」立候補した大学の収益力は | 本当に強い大学 | 東洋経済オンライン https://toyokeizai.net/articles/-/665523?utm_source=rss&utm_medium=http&utm_campaign=link_back 目玉政策 2023-04-12 05:10:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)