是<h1><a ...> ... </a></h1>和<a ...><h1> ... </h1></a>有效的HTML,还是只有一个正确?如果它们都是正确的,它们的含义是否不同?
我正在将 VueJS 项目转换为 Nuxt.js,但我在理解 nuxt 如何处理路由时遇到问题。它的文档没有说任何关于推送路线的内容。
使用 VueJS 我在一个组件中有以下内容。
//template
<input class="" type="search"
name="q" id="q" v-model="q"
@keyup.enter="submitSearch"
>
//script
methods: {
submitSearch() {
this.$route.push({name: 'search', query: {q: this.q}});
//also tried the following
//nuxt.$router.push({name: 'search', query: {q: this.q}});
}
}
Run Code Online (Sandbox Code Playgroud)
但这在 Nuxt 中没有任何作用。发出警报('hi); submitSearch 内部触发很好,但我从未重定向到路由。
这里的目标是当用户在搜索栏中按下 Enter 键时,重定向到 /search?q=blablabla
编辑:
问题是用户被重定向到/?q=blablabla而不是/search?..
我刚刚意识到这是因为多语言路线有不同的名称。
我将如何推送到一个动态search命名的路由名称而不是“ ” search__en?
我正在尝试在我的 Nuxt js 应用程序中安装Vue Typer,但没有成功。我不断收到“文档未定义”。我尝试将它作为插件导入到我的 nuxt.config.js 中,但它不起作用。
我让它在我的 VueCLI 3 中工作,似乎用这种方法工作得很好。
欣赏它!
得到
NuxtServerError render function or template not defined in component: anonymous
////plugins///
import Vue from vue;
if (process.client) {
const VueTyper = require('vue-typer');
Vue.use(VueTyper);
}
///nuxt.config.js///
plugins: [
{src: '~/plugins/vue-typer.js', ssr: false}
],Run Code Online (Sandbox Code Playgroud)
<template>
<vue-typer text='Hello World! I was registered locally!'></vue-typer>
</template>
<script>
const VueTyper = processs.client ? require('vue-typer'): '';
export default {
components: {
VueTyper
}
}
</script>Run Code Online (Sandbox Code Playgroud)
使用 Nuxt,您可以在nuxt.config.js文件中设置语言 HTML 属性,如下所示:
module.exports = {
head: {
htmlAttrs: {
lang: 'en-GB',
},
... etc etc
Run Code Online (Sandbox Code Playgroud)
但是,如果您有一个多语言应用程序,您应该怎么做?有没有办法根据语言环境设置语言属性?
我认为这可能document.documentElement.setSttribute('lang', 'language-code')会起作用,但是由于 nuxt 在服务器端呈现,它似乎无法访问 documentElement 对象。
谢谢
Laravel 7.21 Class Illuminate\Support\Facades\Input not found
我在 app.php 中取了别名,但喜欢
Input' => Illuminate\Support\Facades\Input::class,
Run Code Online (Sandbox Code Playgroud)
像这样写在控制器中
use Illuminate\Support\Facades\Input;
Run Code Online (Sandbox Code Playgroud)
像这样访问
Input::all() , Input::get('name')
Run Code Online (Sandbox Code Playgroud)
Laravel 7.21 版本有什么变化???
我在目录中构建了一个 Vue JS 应用程序dist。为了运行,我使用http-server以下命令全局安装:
npm install -g http-server
Run Code Online (Sandbox Code Playgroud)
我使用以下命令运行应用程序:
http-server dist
Run Code Online (Sandbox Code Playgroud)
所以我可以访问该网站http://localhost:8080,它工作正常。但在我的应用程序中,我vue-router配置了历史记录模式,因此我应该访问类似 的 URL http://localhost:8080/page1,但问题是http-server返回 404:
curl -i http://localhost:8080/page1
HTTP/1.1 404 Not Found
accept-ranges: bytes
Date: Sat, 11 Sep 2021 12:41:53 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 0
Run Code Online (Sandbox Code Playgroud)
我如何解决它?
我正在尝试使用 Composer 创建一个 Laravel 项目,当我运行时
composer create-project laravel/laravel example-app
Run Code Online (Sandbox Code Playgroud)
在终端中,进程停止并出现以下错误:
[RuntimeException]
php: does not exist and could not be created.
Run Code Online (Sandbox Code Playgroud)
我通过 Wampserver 运行 php 7.4,并将其 PATH 添加到环境变量中,当我在终端中运行 php -v 时,一切看起来都很好:
PHP 7.4.0 (cli) (built: Nov 27 2019 10:14:18) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么?我使用的是 Composer 版本 2.1.4,在管理模式下运行命令也没有什么区别。
vue.js ×4
nuxt.js ×3
laravel ×2
nuxt-i18n ×2
php ×2
vue-i18n ×2
composer-php ×1
deployment ×1
html ×1
httpserver ×1
javascript ×1
laravel-7 ×1
semantics ×1
vue-cli ×1
vue-router ×1
vuejs2 ×1