小编dmi*_*er1的帖子

将几个静态属性引入Vue.js

我是Vue.js的新手,我们正在努力将Vue.js逐个添加到现有项目中.我正在努力在Vue中重写产品滑块.它目前正在使用jquery光滑滑块.所以在html中的当前/旧代码中,这个js函数被调用:

function productDetailsRecommendations(compositeNumbers) {
  var params = {
    compositeNumbers: compositeNumbers,
    strategy: 'pp12',
    backupStrategy: 'popular',
    divId: 'recommendedProductsHorizontal',
    isVertical: false,
    isHideHeaderText: false,
    headerText: 'Guests Who Viewed This Item Also Viewed These',
    backupHeaderText: 'Popular Products',
    itemsPerPage: 5,
    itemDisplayLimit: 10,
    numberOfItems: 15,
    responseMap: null
  };

  createSlider(params);
}
Run Code Online (Sandbox Code Playgroud)

现在我正在使用vue-carousel重新创建滑块.所以我用自己复制的函数替换了这个调用:productDetailsRecommendationsVue.

现在我创建了一个ProductRecommendationsSlider.vue作为滑块组件.我有一个index.js作为滑块初始化的入口点.

现在我的老板告诉我,我需要把productDetailsRecommendationsVue功能放进去index.js.

// index.js

import Vue from 'vue';
import axios from 'axios';
import VueCarousel from 'vue-carousel';
import Slider from '/components/slider/ProductRecommendationsSlider'

Vue.use(VueCarousel);

window.productDetailsRecommendationsVue=function(compositeNumbers) {
  var params = …
Run Code Online (Sandbox Code Playgroud)

vue.js vuejs2

6
推荐指数
1
解决办法
959
查看次数

css grid - 匹配自动宽度的动态列数

我真的不认为这应该那么难。我有未知数量的列要在 CSS 网格中显示。我希望所有列的宽度都相同以匹配内容。我希望它是最小内容,这样当文本太长时就会换行。我尝试了许多不同的变化。但本质上,这就是我认为我想要的,并且不确定为什么浏览器在线上显示“无效的属性值” grid-template-columns。

.flyer-container > div {
  width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(auto-fit, minmax(min-content, 1fr));
}
Run Code Online (Sandbox Code Playgroud)

css css-grid

6
推荐指数
0
解决办法
8283
查看次数

ftpwebrequest.getresponse正在抛弃550拒绝访问

我试图找出如何将此文件上传到我在C#中的ftp服务器.当它要求getResponse()在ftpwebrequest它抛出一个错误,指出"550 -访问被拒绝".我无法弄清楚为什么.我可以使用相同的凭据与Filezilla连接到服务器.

这是我的代码连接:

private void UploadFileToFTP(HttpPostedFile file, string server, string user, string pass)
    {
        string uploadUrl = server + file.FileName;
        string uploadFileName = Path.GetFileName(file.FileName);

        Stream streamObj = file.InputStream;
        Byte[] buffer = new Byte[file.ContentLength];
        streamObj.Read(buffer, 0, buffer.Length);
        streamObj.Close();
        streamObj = null;
        try
        {
            SetMethodRequiresCWD();
            FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(uploadUrl);
            //ftp.Method = WebRequestMethods.Ftp.MakeDirectory;
            ftp.Method = WebRequestMethods.Ftp.UploadFile;
            ftp.UsePassive = true;
            ftp.Credentials = new NetworkCredential(user, pass);
            FtpWebResponse CreateForderResponse = (FtpWebResponse)ftp.GetResponse();

            if (CreateForderResponse.StatusCode == FtpStatusCode.PathnameCreated)
            {

                string ftpUrl = string.Format("{0}/{1}", uploadUrl, uploadFileName); …
Run Code Online (Sandbox Code Playgroud)

.net c# ftp

5
推荐指数
1
解决办法
845
查看次数

固定页面,内容在标题后面滚动

我在一个网站上工作。我已经修复了大部分页面,但我希望中间的表格随主滚动条一起滚动。然后我在背景中有一张我想部分显示的图像。我有它主要工作。我唯一无法弄清楚的部分是如何让表格内容在到达标题时落后甚至停止。我将包括一个小提琴,所以你可以看到我在说什么。HTML:

<body>
<div id="background"></div>
<div id="tableBackground"></div>
    <div id="fixedHeader">
        <h1>fixed header</h1>
        <h2>Subheading</h2>
    </div>
    <div id="tableContainer">
        <table class="stocks compact display cell-border">
            <tr><td>row 1 cell 1</td><td>row 1 cell 2</td></tr>
            <tr><td>row 2 cell 1</td><td>row 2 cell 2</td></tr>
            <tr><td>row 3 cell 1</td><td>row 3 cell 2</td></tr>
            <tr><td>row 4 cell 1</td><td>row 4 cell 2</td></tr>
            <tr><td>row 5 cell 1</td><td>row 5 cell 2</td></tr>
            <tr><td>row 6 cell 1</td><td>row 6 cell 2</td></tr>
            <tr><td>row 7 cell 1</td><td>row 7 cell 2</td></tr>
            <tr><td>row 8 cell 1</td><td>row 8 cell 2</td></tr>
            <tr><td>row 9 cell 1</td><td>row 9 …
Run Code Online (Sandbox Code Playgroud)

html css

5
推荐指数
1
解决办法
8443
查看次数

尝试在函数组件之外调用 useContext

我正在尝试弄清楚如何正确使用 React Context。我对尝试从函数组件外部访问上下文的问题感到困惑。我收到错误:

第9:18行:React Hook“useContext”在函数“onDragEnd”中调用,该函数既不是React函数组件,也不是自定义React Hook函数react-hooks/rules-of-hooks

这是我的整个 Schedule js 文件:

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { DragDropContext } from 'react-beautiful-dnd';
import OrderColumn from '../ordercolumn/OrderColumn';
import { ScheduleContext } from '../../schedule-context';

const onDragEnd = (result) => {
    const { destination, source, draggableId } = result;
    const context = useContext(ScheduleContext); // <-- issue is here

    if (!destination) {
        return;
    }

    if (
        destination.droppableId === source.droppableId &&
        destination.index === source.index
    ) {
        return;
    }

    const column …
Run Code Online (Sandbox Code Playgroud)

state reactjs

5
推荐指数
1
解决办法
1万
查看次数

VueJS - 挂载钩子错误:“TypeError: this.$store is undefined”

我的 VueJS 页面出现错误,我一直无法弄清楚。完整的错误是[Vue warn]: Error in mounted hook: "TypeError: this.$store is undefined"。我什至将它缩小到导致它的特定代码行。这是我的 .vue 文件中的相关代码:

 <template>
  <div
    id="recommendedProductsDetailsHorizontal"
    :class="['imageSliderContainer', itemsPerPageCssStyle]"
    style="width:100%;height:374px;">
    <h2>{{ params.headerText }}</h2>
    <div
      class="wrapper"
      style="height:355px;">
      <div class="carousel-view">
        <carousel
          :navigation-enabled="true"
          :min-swipe-distance="1"
          :per-page="5"
          navigation-next-label="<i class='fas fa-angle-right'></i>"
          navigation-prev-label="<i class='fas fa-angle-left'></i>">
          <slide
            v-for="product in products"
            :key="product.id">
            <div class="img-container">
              <a
                href="#"
                class="handCursor"
                tabindex="0">
                <img
                  :src="product.img"
                  :alt="'Product #' + product.id">
              </a>
            </div>
            <h4>Product #{{ product.id }}</h4>
            <div class="price-div">
              <div class="allPriceDescriptionPage">${{ product.price }}</div>
            </div>
            <a
              href="#"
              tabindex="0"
              name="instantadd">
              <div class="btn_CA_Search buttonSearch gradient"> Add to …
Run Code Online (Sandbox Code Playgroud)

vue.js

3
推荐指数
1
解决办法
6868
查看次数

如何使用selectboxit使用jquery重置选择框

我正在使用Fancybox在页面中间弹出一个div,它有一个用selectboxit jquery插件设置样式的选择框:http://gregfranko.com/jquery.selectBoxIt.js/ .现在我将选择值更改为默认值以外的其他值并关闭Fancybox.当我重新打开Fancybox时,选择值仍然与我选择的相同.我需要它重置为默认值.这是我现在的javascript coode:

var selectBox = $("select").selectBoxIt();
        $(".fancybox, #cartLink").fancybox({
            width: 800,
            autoHeight: true,
            minHeight: 385,
            scrolling: 'no',
            autoSize: false,
            afterClose: function () {
                $(selectBox).val('0');
                $(selectBox).refresh();
                console.log('should be reset!');
            }
        });
Run Code Online (Sandbox Code Playgroud)

'afterClose'函数中的前两行不起作用.第一个可能是做某事,但刷新线在Firebug中说:"TypeError:$(...).refresh不是函数$(selectBox).refresh();" 我有什么想法可以重置这个选择框?

编辑:根据要求,这是一个小提琴:http://jsfiddle.net/Qh2NP/1/

jquery jquery-plugins

2
推荐指数
1
解决办法
4155
查看次数

在C#中合并或添加2个元组列表

我有两个List<Tuple<string, int, long>>需要合并的元组列表。我希望第二个列表排在第一个列表之后,因此所有项目都不会混淆。我认为这应该相当容易,但对我的搜索没有任何帮助。

c# tuples list

2
推荐指数
2
解决办法
1620
查看次数

将项目添加到选择列表的末尾

我需要手动将一些项添加到已创建的选择列表的末尾.以下是选择列表的代码:

m.StateList =
    new SelectList(svc.GetStates(user.Login, user.Password), "Key", "Value");
Run Code Online (Sandbox Code Playgroud)

有人能告诉我如何在该列表中添加更多项目吗?我做了很多搜索.

c#

1
推荐指数
1
解决办法
2990
查看次数

[Vue 警告]:缺少必需的道具:“productInfo”

我对 Vue 相当陌生,所以这可能很明显,但我一定遗漏了一些东西。我不断收到错误:[Vue warn]: Missing required prop: "productInfo"在我的 .vue 文件中。它说它在 ProductSlider.vue 中找到。

产品滑块.vue

    <template>
  <div
    id="recommendedProducts">
    <h2>{{ params.headerText }}</h2>
    <div
      class="wrapper">
      <div class="carousel-view">
        <carousel
          :navigation-enabled="true"
          :min-swipe-distance="1"
          :per-page="5"
          navigation-next-label="<i class='fas fa-3x fa-angle-right'></i>"
          navigation-prev-label="<i class='fas fa-3x fa-angle-left'></i>">
          <slide
            v-for="product in products"
            :key="product.id">
            <Product
              :id="product.id"
              :product-info="product"/>
          </slide>
        </carousel>
      </div>
    </div>
  </div>
</template>

<script>
  import Slider from './Slider'
  import Product from './Product'
  import {mapState, mapGetters} from 'vuex'
  import axios from 'axios';

  export default {
    name: "Slider",
    components: {
      Product
    },
    props: { …
Run Code Online (Sandbox Code Playgroud)

vue.js

1
推荐指数
1
解决办法
7752
查看次数

NodeJS - TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。收到未定义

我的 Webstorm 中有一个 Node/React 项目,但由于此错误而无法运行。我不得不重新安装 Windows 并重新开始我的开发。我将代码放回到 IDE 中,但是当我启动 Node 服务器时,出现以下错误:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

该错误的更多上下文:

[nodemon] starting `babel-node src/node-server/index.js`
internal/validators.js:122
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:122:11)
    at Object.join (path.js:375:7)
    at Object.<anonymous> (C:\Projects\Production-Orchestrator\src\node-server\/index.js:17:15)
Run Code Online (Sandbox Code Playgroud)

我去了 index.js,这里是第 1-17 行:

// npm run server
import dotenv from 'dotenv';
import express from 'express';
import path from 'path';
import sql from 'mssql'; …
Run Code Online (Sandbox Code Playgroud)

node.js package.json babeljs

1
推荐指数
1
解决办法
2万
查看次数

可恢复的致命错误:mysqli类的对象无法转换为字符串

一直在墙上撞我的头一段时间。我也阅读了大多数建议的问题。我试图将我的mysqli连接传递到类构造器并将其设置为类变量,并得到:可恢复的致命错误:mysqli类的对象无法转换为字符串

PHP:

$con=mysqli_connect("abc", "abc", "abc", "abc");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MariaDB: " . mysqli_connect_error();
}
/* check connection */
if ($con->connect_errno) {
    printf("Connect failed: %s\n", $con->connect_error);
    exit();
}

$t = new Timer($con);
// lots of irrelevant code
unset($t);

class Timer {
    private $time = null;
    private $con;
    public function __construct($con) {
        $this->$con = $con;
        $this->time = time();
        echo 'Working - please wait..<br/>';
    }

    public function __destruct() {
        $basename = basename($_SERVER['PHP_SELF']);
        $query = "SELECT ScriptID FROM scripts …
Run Code Online (Sandbox Code Playgroud)

php

0
推荐指数
1
解决办法
3772
查看次数

ReactJS - 从数据库获取数据并从 .then 返回到返回函数返回承诺结果

太长了;基本上,我试图弄清楚如何在加载时将数据从我的 api 获取到我的 React 应用程序中,以便我的应用程序立即可用。如果需要的话,我完全可以重做或重新编写下面的任何或全部代码。我只需要弄清楚如何做到这一点。我认为它需要进入上下文,以便我的所有组件都可以访问它。

我使用硬编码的虚拟数据创建了一个 ReactJS 应用程序,并且效果很好。现在我们需要将其转换为从数据库中提取真实的动态数据,并且无法理解 Promise 如何与状态和 useEffect 一起工作。它变得如此令人困惑。我在最后一次调用中创建 contextValue 对象,.then并且我需要在return. 我尝试将其保存到状态变量,但这似乎不起作用。TypeError: _useContext is null我在另一个文件中收到错误。

这是整个上下文文件,其中删除了所有不相关的代码:

import PropTypes from 'prop-types';

export const ScheduleContext = createContext();

export const ScheduleProvider2 = (props) => {
    const allChemicals = [...];

    const allBOMs = [...];

    const makeRandomStr = (length) => {...};

    const getRandomChemicals = () => {};

    const getRandomBOMs = () => {..};

    const getRandomIntInclusive = (min, max) => {...};

    const randomDate = (start, end, …
Run Code Online (Sandbox Code Playgroud)

javascript promise reactjs

-2
推荐指数
1
解决办法
157
查看次数