midnightelf18's questions
有.php
一个文件,它包含带有插入的标记<?php echo $foo; ?>
。我像这样在控制器中获取此文件
$content = file_get_contents('/path/to/file.php');
很明显,当它读取文件时,它不会执行 PHP 代码,而只是将其作为字符串读取(虽然在使用时, file_get_contents()
它会将 PHP 代码包装在 HTML 注释中,但无论如何)。如何确保在读取文件时,插入其中的 PHP 代码被执行,然后我可以得到它插入的内容?
include, require...
不适合,因为我需要将文件的执行内容写入变量
这就是我请求获取组件中数据的方式:
computed: {
...mapGetters([
'showNews'
]),
},
mounted() {
this.$store.dispatch('newsById', this.id /* в компонент передается props id */);
}
newsById
在action
store/index.js中看起来像这样:
newsById({ commit }, id) {
axios.get(`/news/${id}`, apiConfig)
.then(response => {
console.log(response);
commit('newsByIdMutation', response);
})
}
newsByIdMutation
在mutations
store/index.js中看起来像这样:
newsByIdMutation(state, newsById) {
state.showNews = newsById.data;
}
{{ showNews.title }}
在组件的标记中,我试图以这种方式访问该对象{{ showNews.text }}
。但我得到一个错误:Uncaught (in promise) TypeError: Cannot read property 'title_img' of undefined
。我如何在我得到的对象中获取这些属性?
laravel 8 上有一个项目,前面是用 vue 3 编写的。在前面,当用户使用 导航路径时router-link
,router-view
会加载并显示组件。例如,如果router-link
用户导航到/overview/12
,router-view
加载他的组件,但是当用户在同一路径上并重新加载页面时,则会显示laravel
第错误页面模板,404
表示没有这样的路由。
如何使所有路由/api/*
(我发出 RESTapi 请求的地方除外)使用vue-router
.
resorces/js/router/index.js
:
import IndexSlider from "../components/IndexSlider";
import Newsfeed from "../views/Newsfeed";
import Overview from "../views/Overview";
const routes = [
{
path: '/',
name: 'index',
redirect: '/index'
},
{
path: '/index',
name: 'index-slider',
component: IndexSlider,
children: [
{
path: 'newsfeed',
name: 'newsfeed',
component: Newsfeed
}
]
},
{
path: '/overview/:id',
name: 'overview',
component: Overview,
props: true
}
]
export default routes;
web/web.php
:
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\IndexController;
Route::get('/{vue_capture?}', function () {
return view('index');
})->where('vue_capture', '[\/\w\.-]*');
/routes/api.php
:这些路线应该适用于查询axios
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\NewsController;
Route::resource('news', NewsController::class);
vue@3.0.5
... vue-router@4.0.3
_laravel 8
我有一个包含项目的 docker 容器。我可以连接到容器 fs 并使用Visual Studio Code及其Remote-WSL和Remote-Containers扩展修改项目。那些。我按照 docker 的远程 wsl 页面所示进行操作。我也想通过 phpstorm 连接,我在市场上没有找到这样的扩展,并想通过创建符号链接来实现ИЗ_WSL2 -> В_WINDOWS
,但我在 WSL 中没有项目文件夹,我不知道如何将项目文件夹从容器连接到 WSL。好吧,这里有两种方法。
- 从 phpstorm 直接连接到 fs docker 容器
PhpStorm -> DOCKER_CONTAINER
(就像我使用 VS Code 一样) - 以某种方式将 docker 容器中的目录连接到 WSL(我有 Ubuntu-20.04 LTS)并从中打开项目。(有一种方法可以在 phpstorm 中从 wsl 打开一个项目。使用相同的符号链接)
DOCKER_CONTAINER -> WSL2 -> PhpStorm
我用谷歌搜索并没有找到第一个或第二个问题的答案。有没有人经历过这个并且知道该怎么做?
这两个选项中的 ps 比第二个更可取。因为 wsl 可以从 explorer ( \\wsl$\Ubuntu-20.04
) 访问,并且使用起来更方便
我有一个 laravel 项目。我正在使用 laradock 环境来运行该项目。我这样做是为了运行
docker-compose up -d workspace mysql php-fpm
docker-compose exec workspace bash
cd ПАПКА_ПРОЕКТА
php artisan serve
它,但问题是在运行最后一个命令 ( serve
) 后它会显示在控制台中
Starting Laravel development server: http://127.0.0.1:8000
,这是值得的。服务器没有启动。
工作区 ( ) 中的 PHP 版本php -v
:
PHP 7.3.27-1+ubuntu18.04.1+deb.sury.org+1 (cli)(构建:2021 年 2 月 7 日 11:57:25)(NTS)
工作区中的分布 ( neofetch
):
Ubuntu 18.04.5 LTS x86_64
主机:虚拟机 Hyper-V UEFI 版本 v4.0
总的来说,我的 laradock 表现得很奇怪。例如,还有其他东西工作npm run dev
非常缓慢并且npm run watch
收集速度也同样缓慢,但另外它还没有这样做watch
。更改文件时,
nodejs( node -v
) 不会更新:
7.5.3
npm( npm -v
):
v15.8.0
我试图做的事情:
- 重新安装 Docker、Laradock、WSL2
- 将 Docker 从 WSL2 切换到 Hyper-V,反之亦然
- 在 Docker 中使用基于 WSL2 的引擎
- 在 Docker 中清理/清除数据
- 工作区中的 apt update && apt 升级
我什至不知道问题出在哪里
。这里有一些项目配置:
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.21",
"bootstrap": "^4.0.0",
"jquery": "^3.2",
"laravel-mix": "^6.0.0-beta.17",
"lodash": "^4.17.19",
"popper.js": "^1.12",
"postcss": "^8.1.14",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
"vue": "^3.0.5",
"vue-loader": "^16.1.2",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"@vue/compiler-sfc": "^3.0.5",
"swiper": "^6.4.11"
}
}
拉拉维尔(php artisan --version
):
Laravel 框架 8.26.1
docker -compose.yml laradock
.env laradock
time npm run dev
真实 1m1.804s
用户 0m16.883s
系统 0m6.296s
ps也许您需要更改某些内容,因为当我取消注释Windows 10中的php.ini
问题时,我设法在工作区之外重现了此问题php.ini-development
在这个布局上,我们看到有一个带有新闻的区块,并且在这个区块中有新闻卡片。但是,如果您仔细观察,您会发现这些卡片的排列打破了行,并且第二行的卡片“浮动”到了第一行(第三行的卡片浮动到了第二行,等等)。
到目前为止,我只能这样做:
* {
box-sizing: border-box;
}
a {
color: inherit;
text-decoration: inherit;
}
body {
margin: 0;
}
.newsfeed-news-cards {
display: flex;
flex-flow: row wrap-reverse;
justify-content: space-between;
padding: 0 8em;
align-items: baseline;
}
.news-card__title.index-swiper-slide-info__title {
font-size: 1.2em;
font-weight: 500;
margin: 12px 0;
}
.news-card__tag.index-swiper-slide-info__tag {
font-family: 'Raleway', 'Montserrat', sans-serif;
font-weight: 300;
font-size: 1.1em;
/* line-height: 1.5em; */
margin: 6px 0;
}
.news-card-footer {
font-family: 'Montserrat', 'Raleway', sans-serif;
color: #BDBDBD;
font-size: 1em;
}
.news-card-footer-views {
display: flex;
align-items: center;
}
img.news-card-footer-views__icon {
margin-right: .5em;
}
.news-card {
max-width: 400px;
}
.news-card__image {
width: 100%;
}
.news-card-footer {
display: flex;
justify-content: space-between;
width: 50%;
}
.news-card-footer-views {
color: #BDBDBD;
}
.news-card-footer-views__icon {
width: 16px;
}
.newsfeed-news__title {
margin-bottom: 2em;
}
.newsfeed-more-load {
display: flex;
margin-top: 3em;
justify-content: center;
}
.newsfeed-more-load__btn {
display: flex;
align-items: center;
}
.newsfeed-more-load__btn {
font-family: "Raleway", sans-serif;
font-weight: 500;
color: #CB9374;
}
.newsfeed-more-load__btn:hover path,
.newsfeed-more-load__btn:hover {
background-color: #CB9374;
color: #fff;
stroke: #fff;
}
.newsfeed-more-load__arrow {
margin-left: 10px;
transform: rotate(-90deg);
}
.index-swiper-slide-info__tag {
text-transform: uppercase;
color: #CB9374;
}
.index-swiper-slide-info__title {
font-family: 'Lora', sans-serif;
color: #333;
font-weight: 700;
font-size: 1.5em;
margin: 1em 0;
}
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;500&family=Montserrat:wght@400;500;600&family=Raleway:wght@400;500;600&display=swap" rel="stylesheet">
<title>so</title>
</head>
<body>
<div class="newsfeed-news">
<div class="newsfeed-news-cards">
<div class="news-card">
<img src="https://i.ibb.co/6X228Zj/news-image.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/RPp1jVG/news-image1.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/ssMP4zb/news-image2.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/hfHNNmF/news-image3.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/ssMP4zb/news-image2.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/RPp1jVG/news-image1.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/HPgrBG7/news-image4.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/ssMP4zb/news-image2.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
<div class="news-card">
<img src="https://i.ibb.co/RPp1jVG/news-image1.png" alt="" class="news-card__image" />
<div class="news-card__tag index-swiper-slide-info__tag">коронавирус</div>
<div class="news-card__title index-swiper-slide-info__title">Эксперт назвал отличия между первой и второй волнами COVID-19</div>
<div class="news-card-footer">
<div class="news-card-footer__post-date">2 часа назад</div>
<div class="news-card-footer-views">
<img src="https://i.ibb.co/yYj3Z4j/eye.png" alt="" class="news-card-footer-views__icon">
<span class="news-card-footer-views__count">178</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
怎么弄成这样?或者如何使第二行的块浮动到第一行?
Menu.vue
有这么一个组件Menu.vue
就是子组件
<aside class="aside">
<img src="@/assets/logo.svg" alt="expocar" class="aside__logo" @click="hideAllLayouts">
<div class="aside-links">
<div class="aside-links__link" data-layout-id="features" @click="toggleLayout($event)">Особенности</div>
<div class="aside-links__link" data-layout-id="advantages" @click="toggleLayout($event)">Преимущества</div>
<div class="aside-links__link" data-layout-id="feedback" @click="toggleLayout($event)">Связаться с нами</div>
<div class="aside-links__shit"></div>
</div>
<div class="placeholder"></div>
</aside>
export default {
name: 'aside',
methods: {
toggleLayout(event) {
this.$emit('toggle-layout', event.target.dataset.layoutId);
},
hideAllLayouts() {
this.$emit('hide-all-layouts');
}
}
}
可以看出,有两种方法发出两个事件toggle-layout
和hide-all-layouts
. 这些方法在点击相应元素时被调用(点击.aside__logo
事件触发hide-all-layouts
,点击.features .advantages .feedback
事件触发toggle-layout
)
App.vue
和组件App.vue
是父级Menu.vue
<Menu id="menu" @toggle-layout="toggleLayout" @hide-all-layouts="hideAllLayouts" />
所以我试图拿起这两个事件。他失败了。谷歌搜索,还不够
如何将两个事件传递给父级?
有这个表格:
.header-search {
padding: 16px;
background-color: #ff000080;
}
.header-icon.header-search__icon {
width: 20px;
height: 20px;
}
.header-search__input {
border: none;
/* outline: none; */
font-size: 1.2em;
width: 100%;
font-family: 'Montserrat', sans-serif;
}
.header-search__input::placeholder {
color: #BDBDBD;
font-family: 'Raleway', 'Montserrat', sans-serif;
}
.header-search {
width: 160px;
display: flex;
align-items: center;
}
<form action="search" class="header-search">
<input type="text" class="header-search__input" placeholder="Поиск">
<img src="https://i.ibb.co/vs0dmRq/search.png" class="header-search__icon header-icon" alt="">
</form>
焦点打开时如何使.header-search__input
背景颜色.header-search
变为蓝色。
upd:最好带有动画
upd:我希望它纯粹在 css 中。但如果它是关键的 js 也是可能的
有一个这样的文件夹结构./src/scss/
:
--> scss
----> root.scss
----> header.scss
----> body.scss
----> footer.scss
那些。文件夹中scss
有 4 个文件.scss
。我正在尝试将它们捆绑在一起app.css
,但它不起作用。
因此,webpack.mix.js
我尝试这样做:
mix.sass(
[
'./src/scss/root.scss',
'./src/scss/header.scss',
'./src/scss/body.scss',
'./src/scss/footer.scss'
], './dist/app.css'
)
但我得到一个错误
AssertionError [ERR_ASSERTION]: mix.sass() is missing required parameter 1: src
他也这样做了:
mix.sass('./src/scss/root.scss', './dist/app.css')
.sass('./src/scss/header.scss', './dist/app.css')
.sass('./src/scss/body.scss', './dist/app.css')
.sass('./src/scss/footer.scss', './dist/app.css');
但所以他只写了app.css
出来footer.scss
¯\_(ツ)_/¯
如何从 laravel-mix 中的 .sass 文件制作一个包?
我正在向return
返回生成的 html 的地址发出请求。
请求代码如下所示:
document.addEventListener("DOMContentLoaded", function() {
axios.get("/get-cards")
.then(response => {
document.getElementById("load").remove();
$("#content").html(response.data);
})
.catch(error => {
console.log(`ERROR: ${error}`);
});
});
生成 html 的页面(位于 /get-cards)如下所示:
@foreach($technics as $technic)
<div class="technic-card">
<div class="card-img">
<div style="background-image: url('{{ $technic->img_1 }}'" alt="{{ $technic->name }}">
<div style="background-image: url('{{ $technic->img_2 }}'" alt="{{ $technic->name }}">
<div style="background-image: url('{{ $technic->img_3 }}'" alt="{{ $technic->name }}">
</div>
<div class="card-name">{{ $technic->name }}</div>
<div class="card-type">{{ $technic->type }}</div>
<div class="card-footer">
<div class="card-price">{{ $technic->price }}/час</div>
<div class="card-buy-btn">арендовать</div>
</div>
</div>
@endforeach
我需要一个现成的带有加载图片的 html 来添加到页面中,但是会出现以下情况。
- 加载页面,从该页面发送请求,然后将响应发送到该页面(html标记)并添加
- 加载指示灯亮
- 请求返回响应
- 加载指示器已移除
- 将html代码添加到页面
- 和图片开始加载 它看起来像这样
我怎样才能让加载指示器在图片加载之前不会消失?
我GET
向页面发出请求以加载内容,使用axios
文件app.js
的请求:
const axios = require("axios");
document.addEventListener("DOMContentLoaded", function() {
axios.get("/get-cards")
.then(response => {
$("#content").html(response.data)
})
.catch(error => {
console.log(`ERROR: ${error}`)
});
});
它所在的页面#content
:
<div id="content">
<!-- сюда загружается контент -->
</div>
请求发送到的页面(在“/get-cards)”:
@foreach($technics as $technic)
<div class="technic-card">
<div class="card-img-slider">
<img src="{{ $technic->img_1 }}" alt="{{ $technic->name }}">
<img src="{{ $technic->img_2 }}" alt="{{ $technic->name }}">
<img src="{{ $technic->img_3 }}" alt="{{ $technic->name }}">
</div>
<div class="card-name">{{ $technic->name }}</div>
<div class="card-type">{{ $technic->type }}</div>
<div class="card-footer">
<div class="card-price">{{ $technic->price }}/час</div>
<div class="card-buy-btn">арендовать</div>
</div>
</div>
@endforeach
并且当页面所在的#content
页面加载1-2秒时,如何让在请求完成之前#content
(div
带有加载动画的块)而不是加载窗口有一个加载指示器?
我创建了一个像这样的 vue 组件:
Vue.component("modal", {
props: ["description", "header", "closeFunction", "detailLink"],
template: "<transition name='bounce'>" +
"<div class='wrapper' @click='closeFunction'>" +
"<div class='container'>" +
"<div class='close_button' @click='closeFunction'></div>" +
"<h3>{{ header }}</h3>" +
"<div class='content'>{{ description | truncate(300) }}</div>" +
"<a v-bind:href='detailLink' class='custom-btn btn-1'>Подробнее</a>" +
"</div></div>" +
"</transition>"
});
并尝试在页面上使用它:
<modal v-show="show"
v-bind:header="header"
v-bind:description="description"
v-bind:close-function="closeModal"
v-bind:detail-link="{{ route("detail-page", id) }}"> // ошибка
</modal>
从组件的调用中可以看出,我正在尝试使用该函数route()
并将Laravel
第二个参数传递给它id
位于$data.id
( data: { id: ... }
) 中的属性,以便web.php
使用Route::get("/detail/{id}"...)
. 正因为如此,它laravel
自然会产生错误"id" is not defined
。我在文档中没有找到任何东西。
如何使 vue 对象属性传递给 laravel route() 函数?
UPD:vue.js 对象
let modal = new Vue({
el: "#modal",
data: {
header: '',
description: '',
id: 0, // вот это свойство нужно использовать как второй аргумент route()
show: false
},
methods: {
closeModal() {
this.show = false;
}
}
});
属性值header
, description
, id
,show
通过调用函数来改变
在应用程序中,laravel
我向post
返回json
对象的地址发送请求。当我在本地服务器上运行应用程序时php artisan serve
,post
请求http
当然是不允许的。为了解决这个问题,我启动ngrok
了一个具有安全连接的服务器,但即便如此,
如果您单击地址栏上的键,错误代码仍然是一样的:
请求如下所示:
axios.post("/modal-info", { id: 1 })
.then(async res => {
console.log(await res)
})
.catch(error => {
console.log(error);
})
PSaxios.get("/modal-info").then(...)
从地址成功返回对象
PS 我会打开几个小时https://c1597888ac87.ngrok.io
有一个文件组件parkInfo.vue
,我试图传递main.js
该组件的注册位置,即输入参数park
。
main.js 我在这里注册组件
Vue.component(
"popup",
require("./vue-components/parkInfo.vue").default,
{
props: [ "park" ]
});
parkInfo.vue本身就是这个组件
<template>
<div>
<div class="modal-header">
<h1>...</h1>
<h2>{{ park }}</h2>
</div>
<div class="modal-body">
{{ ... }}
</div>
</div>
</template>
<script>
...
</script>
home.blade.php这里使用这个组件
<div id="modal">
<popup park="Какой то известный парк"></popup>
</div>
PS如果您声明一个属性park
并保留它,例如文档中所说的空值(“”),那么vue将完全使用这个值,而不是输入参数中传递的值
我正在尝试.json
从three.js
. 但问题是three.js
格式.json
的使用已被弃用,但我仍然需要它。所以我开始寻找其他方法,并找到了提供此功能的存储库。但是当我尝试在连接模块的情况下构建项目时,webpack
在终端出现以下错误
。然后我安装了这个模块npm i fs
,终端出现同样的错误,浏览器控制台出现以下错误
。我将模块连接到index.js像这样:
const LegacyJSONLoader = require('three-legacyjsonloader');
...
<br/>**webpack.config.js:**
```javascript
const path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
}
}
包.json:
{
"name": "_____",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"dependencies": {
"fs": "0.0.1-security",
"three": "^0.119.1",
"three-legacyjsonloader": "^1.0.6", // модуль для загрузки *.json в three.js
"three.interaction": "^0.2.3"
},
"devDependencies": {
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
}
}
PS我不使用任何模块方法three-legacyjsonloader
,我只是连接
我有一个cars_catalog
最初有 250 个条目的表。从表中删除一些行后,剩下 187 条记录,id
违反了顺序,即 以前有订单id
,1..250
现在1..15,17,66..112.. и т.д.
。如何使字段值id
成为1..187
?
要求id
:id INTEGER PRIMARY KEY AUTO_INCREMENT
我正在尝试布置这样一个块,其中包含三个在中心对齐的行中的块,并且在背景上有这样的“条纹”。我是这样做.frame::before
的,但它超出了界限.frame
。我怎样才能使它的.frame::before
宽度100%
相对于.frame
?
.frame {
width: 100%;
height: 256px;
display: flex;
background-color: red;
justify-content: center;
align-items: center;
box-sizing: border-box;
margin: 12px;
}
.block {
height: 200px;
width: 128px;
background-color: chocolate;
margin: 0 24px;
border-radius: 8px;
z-index: 0;
}
.frame::before {
position: absolute;
content: "";
background-color: deepskyblue;
width: 100%;
height: 128px;
/*! margin-top: 64px; */
display: inline-block;
}
<div class="frame">
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</div>
我正在制作一个表格来发送带有两个附件的电子邮件。仅当我不使用ajax
请求时发送电子邮件才有效。那些。当脚本未连接main.js
并提交表单 ( submit
) 时,则成功发送带有附件的信件。但是当我提交与连接相同的表单时main.js
,ajax
请求成功但附件未发送
main.js
document.addEventListener("DOMContentLoaded", function() {
alert("ready");
$('#visa-form').submit(function(e) {
var $form = $(this);
$.ajax({
type: $form.attr('method'),
url: "mail.php",
data: $form.serialize()
}).done(function() {
alert("Заявка на визу отправлена успешно");
}).fail(function() {
alert("Произошла ошибка при отправке заявки");
});
e.preventDefault();
});
});
邮件.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
$message = '';
function clean_text($string)
{
$string = trim($string);
$string = stripslashes($string);
$string = htmlspecialchars($string);
return $string;
}
$mail = new PHPMailer;
$mail->CharSet = "utf-8";
try
{
if(isset($_POST["user_fullname"]))
{
$user_photo = 'uploads/' . $_FILES["photo_scan"]["name"];
$user_passport_scan = 'uploads/' . $_FILES["passport_scan"]["name"];
move_uploaded_file($_FILES["photo_scan"]["tmp_name"], $user_photo);
move_uploaded_file($_FILES["passport_scan"]["tmp_name"], $user_passport_scan);
$message = '
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<h3 align="center">Заявка с сайта tulpantravel.ru</h3>
<table border="1" width="100%" cellpadding="5" cellspacing="5">
<tr>
<td width="30%">ФИО</td>
<td width="70%">' . $_POST["user_fullname"] . '</td>
</tr>
<tr>
<td width="30%">Пол</td>
<td width="70%">' . $_POST['user_gender'] . '</td>
</tr>
<tr>
<td width="30%">Номер телефона</td>
<td width="70%">' . $_POST["user_phone"] . '</td>
</tr>
<tr>
<td width="30%">Электронная почта</td>
<td width="70%">' . $_POST["user_email"] . '</td>
</tr>
<tr>
<td width="30%">Место работы</td>
<td width="70%">' . $_POST["user_workplace"] . '</td>
</tr>
</table>
';
$mail->IsSMTP();
$mail->Host = 'smtp.mail.ru';
$mail->Port = '465';
$mail->SMTPAuth = true;
$mail->Username = '*********';
$mail->Password = '*********';
$mail->SMTPSecure = 'ssl';
$mail->From = '*********';
$mail->FromName = '*********';
$mail->AddAddress('***********', '********');
$mail->IsHTML(true);
$mail->AddAttachment($user_photo);
$mail->AddAttachment($user_passport_scan);
$mail->Subject = 'Заявка с сайта **********';
$mail->Body = $message;
if($mail->Send())
{
// ready
}
else
{
// failure
}
}
}
catch (Exception $error)
{
echo 'Произошла ошибка при отправке запроса: ' . $mail->ErrorInfo;
}
finally
{
// finally
}
索引.php
<div id="su-re-modal" class="form">
<div class="modal-title" style="margin-bottom: 20px;">
<div class="modal-title">Заявка на визу</div>
<div class="modal-close su-re-modal_close"></div>
</div>
<form id="visa-form" method="post" action="mail.php" enctype="multipart/form-data">
<div class="form-group">
<label>ФИО</label>
<input type="text" name="user_fullname" class="form-control" required/>
</div>
<div class="form-group">
<label>Пол</label>
<select name="user_gender" class="form-control">
<option value="Мужской">Мужской</option>
<option value="Женский">Женский</option>
</select>
</div>
<div class="form-group">
<label>Номер телефона</label>
<input type="text" name="user_phone" class="form-control" pattern="\d*" required/>
</div>
<div class="form-group">
<label>Эл. почта</label>
<input type="email" name="user_email" class="form-control" required/>
</div>
<div class="form-group">
<label>Место работы</label>
<input type="text" name="user_workplace" class="form-control" required/>
</div>
<div class="form-group">
<label>Загрузить фото</label>
<input type="file" name="photo_scan" required/>
</div>
<div class="form-group">
<label>Загрузить скан паспорта</label>
<input type="file" name="passport_scan" required/>
</div>
<div class="form-group" align="center">
<input type="submit" name="submit" value="Отправить заявку" class="btn btn-info" />
</div>
</form>
</div>
<script src="jquery-3.5.1.min.js"></script>
<script src="main.js"></script>
PS所有三个文件都在同一个目录中
$(".modal-window").on("click", (e) => {
let $html = $(e.target).parent()[0];
console.log($html);
});
.modal-window {
background: gray;
padding: 12px;
width: 128px;
border-radius: 12px;
margin: 6px;
display: inline-block;
}
.modal-title {
color: #fff;
}
.apply-button {
background-color: #fff;
padding: 4px;
text-align: center;
margin: 4px auto;
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="modal-window">
<div class="modal-title">
<div class="modal-title">Текст который нужно достать 1</div>
<div class="modal-close hadjj-combined_close"></div>
</div>
<div class="modal-content">
<div class="md-content">
<div class="md-title">Программа включает:</div>
<div class="md-cond">
... Какой-то HTML
</div>
</div>
</div>
<div class="apply-button">Достать текст</div>
</div>
<div class="modal-window">
<div class="modal-title">
<div class="modal-title">Текст который нужно достать 2</div>
<div class="modal-close hadjj-combined_close"></div>
</div>
<div class="modal-content">
<div class="md-content">
<div class="md-title">Программа включает:</div>
<div class="md-cond">
... Какой-то HTML
</div>
</div>
</div>
<div class="apply-button">Достать текст</div>
</div>
<div class="modal-window">
<div class="modal-title">
<div class="modal-title">Текст который нужно достать 3</div>
<div class="modal-close hadjj-combined_close"></div>
</div>
<div class="modal-content">
<div class="md-content">
<div class="md-title">Программа включает:</div>
<div class="md-cond">
... Какой-то HTML
</div>
</div>
</div>
<div class="apply-button">Достать текст</div>
</div>
单击特定按钮的输出如下:
<div class="modal-window">
<div class="modal-title">
<div class="modal-title">Текст который нужно достать 2</div>
<div class="modal-close hadjj-combined_close"></div>
</div>
<div class="modal-content">
<div class="md-content">
<div class="md-title">Программа включает:</div>
<div class="md-cond">
... Какой-то HTML
</div>
</div>
</div>
<div class="apply-button">Достать текст</div>
</div>
如何从那里获得带有文本“Text to get $”的元素?