RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-195703

Rumata's questions

Martin Hope
Rumata
Asked: 2022-06-24 21:17:36 +0000 UTC

JS:配置器有问题

  • 1

学习 JS,试图从 HTML Acedemy 解决一个问题,得到奇怪的错误。

任务如下所示:

let materialPrice = {
  'wood': 1000,
  'stone': 1500,
  'brick': 2000
};

let house = {
  rooms: 10,
  floors: 5,
  material: 'wood',
  coefficient: 10.5
};

/* Техническое задание

Мяу! Допиши за меня конфигуратор. Я создал объект house и задал ему несколько свойств: rooms (количество комнат), floors (этажи), material (материал для стен), coefficient (средняя площадь каждой комнаты).

Ещё я завёл мапу materialPrice, в которой записал стоимость каждого возможного материала для строительства.

Добавь в объект два метода: calculateSquare, который будет возвращать площадь дома, и calculatePrice, который будет возвращать стоимость строительства.

Площадь считай так: умножь количество комнат на коэффициент и число этажей в доме.

Цена строительства — произведение площади и стоимости материала дома.

*/

这是我的解决方案:

let materialPrice = {
  'wood': 1000,
  'stone': 1500,
  'brick': 2000
};

let buildHouse = function (rooms, floors, material, coefficient) {
  
let house = {
  rooms: 10,
  floors: 5,
  material: 'wood',
  coefficient: 10.5,

  calculateSquare: function () {
    return this.rooms * this.coefficient * this.floors;
    },
    
  calculatePrice: function () {
    return calculateSquare * materialPrice[this[material]];
    }
}  


return house;
}

buildHouse();

我收到一个错误

在此处输入图像描述

我尝试了不同的选项,包括通过函数传递的映射属性:

 let house = {
      rooms: rooms,
      floors: floors,
      material: material,
      coefficient: coefficient
    };

尝试在 home 对象下创建和调用函数。尝试了很多东西,要么删除了房子对象,要么没有定义 calculateSquare 方法。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2022-06-14 02:04:27 +0000 UTC

如何在不传递所有参数的情况下调用函数?

  • 0

有一个函数最多接受 4 个参数。同时,在不同的情况下,我会调用它并只传递 3、2 或 1 个参数。Unity 会抛出一个错误,如果在函数中设置了参数,则必须传递它。有没有办法将参数指定为可选,或者使用另一种解决方案(哪个)更好?

例子:

void example(Texture texture1, Texture texture2, Texture texture3, Texture texture4) {

  renderer1.material.mainTexture = texture1;

  if (texture2 != null) {
    renderer2.material.mainTexture = texture2;
  }
  if (texture3 != null) {
    renderer3.material.mainTexture = texture3;
  }
  if (texture4 != null) {
    renderer4.material.mainTexture = texture4;
  }

}

public void callExample(){
     example(texture1, texture2);
};
c#
  • 3 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-08-23 04:36:58 +0000 UTC

Xcode 9:从后台线程调用的 UI API

  • 2

最简单的 ARKit 应用程序无法启动。只是 ARKit for Unity 的原始演示场景。
- 我为 Ios 导出,通过 XCode 9 安装,一切正常。
- 我启动:“等待编辑器连接...”挂在 iPhone 屏幕上,在 Xcode 中有很多警告和一个错误:“从后台线程调用 UI API”、“必须从主线程使用 UIApplication 委托”只要”。

在此处输入图像描述

我是新手,还没有在 Objective-C 中工作,但从这样的教程来看,情况不应该如此。

可能是什么问题以及如何解决?
提前非常感谢!

ios
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-05-03 05:16:07 +0000 UTC

你怎么知道动画已经结束了?

  • 2

统一,C#。有一个带有动画器的模型,其中已经配置了动画状态和它们之间的转换参数。

我需要按特定顺序播放动画。要调用所需的动画,我只需要检查所需的参数:

GetComponent.<Animator>().SetBool("someparameter",true);

如何编写“当前动画结束时”的条件?我找到的所有选项要么是 about Animation, not Animator,要么太复杂,但我需要一种您可以快速理解和使用的简单方法。

c#
  • 2 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-04-18 01:53:11 +0000 UTC

一个简单的 if 条件不起作用,错误可能在哪里?

  • 3

Unity 脚本,但也许这只是一个我没有看到的明显 C# 错误……
有一个脚本可以逐个字母地“打印”文本。它应用于按钮按钮的文本(文本,按钮的后代)。您希望脚本仅在按钮可单击(可交互)时运行。

我创建了一个公共变量来在 Unity 中将一个按钮拖入其中并使用了 GetComponent() 但由于某种原因它不起作用。

下面是一个简短的脚本。为什么没有成功,错误在哪里?提前致谢!

UPD 脚本略有更新但仍无法正常工作。


using UnityEngine;
using System.Collections;
using UnityEngine.UI;

// attach to UI Text component (with the full text already there)

public class UITextTypeWriter : MonoBehaviour {


public Text txt;
string story;
 public Button ThisButton;

void Start()
{
    txt = GetComponent<Text>();
    story = txt.text;
    txt.text = "";



        if (ThisButton.interactable) {
            StartCoroutine(PlayText());
        }
    }

IEnumerator PlayText()
{
    foreach (char c in story)
    {
        txt.text += c;
        yield return new WaitForSeconds(0.125f);
    }
}

}
c#
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-03-05 02:59:15 +0000 UTC

为什么 jQuery UI 手风琴不起作用?

  • 0

我正在学习JS。我正在尝试使用 jQuery UI 制作手风琴。由于某种原因它不起作用,很长一段时间我一直在试图理解为什么,可能是怎么回事?非常感谢!

$(function() {
  $("#accordion").accordion();
});
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Timer</title>


</head>

<body>
  <div id="accordion">
    <h1><a href=#>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a></h1>

    <h3><a href=#>Nulla non eleifend magna. Proin luctus ante ac felis blandit vestibulum.</a></h3>
    <div id="first">
      <p>Suspendisse potenti. Donec non venenatis lectus, sagittis faucibus est. Pellentesque lacinia ut odio nec semper. Maecenas eros massa, tristique ut nunc eget, fermentum tempor sapien. Vestibulum arcu leo, condimentum ut augue non, dapibus scelerisque
        dolor. Pellentesque pellentesque eget nisi at elementum. Etiam eu ante lacus. Etiam lacinia malesuada nisi a ullamcorper. Sed faucibus imperdiet elit, sed posuere tortor porttitor at. Curabitur nisi ante, rhoncus ut est nec, euismod elementum
        elit. Maecenas at condimentum lorem, ac posuere velit.</p>
    </div>

    <h3><a href=#>In dignissim, dui non euismod dictum, dolor dolor accumsan arcu, vel ornare elit velit at leo.</a></h3>
    <div>
      <p>Curabitur aliquam tellus non metus luctus, ac mattis lectus vehicula. Duis gravida facilisis sapien, facilisis sodales enim semper ut. Curabitur porta magna eu metus posuere, rutrum eleifend nulla imperdiet. Suspendisse a dui blandit, mattis augue
        et, ultricies diam. Phasellus tincidunt dui et orci bibendum, sit amet mollis nunc convallis. Duis ac ullamcorper tellus, a viverra ante.</p>
    </div>

    <h3><a href=#>Cras tincidunt leo non quam efficitur, eget scelerisque tortor tempor.</a></h3>
    <div>
      <p>Quisque elementum augue ac feugiat sodales. Nam auctor libero at semper aliquet. Nam convallis est nec nisl aliquet bibendum. Sed volutpat sed nisl nec laoreet. Donec dignissim felis a ipsum pellentesque ultrices. Integer vulputate tristique lectus
        quis venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed tempor nisl ipsum, at vestibulum nulla sagittis vitae. Phasellus at nunc ut odio dictum faucibus.</p>
    </div>

    <h3><a href=#>Ut ex nisl, ultrices vel sagittis bibendum, mollis efficitur ipsum.</a></h3>
    <div>
      <p>Aenean vitae lorem libero. Suspendisse venenatis, libero viverra aliquet facilisis, dui diam egestas nibh, at luctus augue est sit amet lorem. Phasellus non turpis vulputate, lacinia erat et, condimentum lorem. Curabitur ipsum sapien, interdum eget
        tincidunt at, placerat sed tellus. Nam purus orci, facilisis egestas porta sed, tempor id justo. Fusce elementum, diam sed fringilla congue, erat lectus pharetra purus, et ornare risus velit sit amet risus. Proin eu lorem odio. Nullam eu condimentum
        nibh.
      </p>
    </div>

    <h3><a href=#>Praesent quis lacus posuere, viverra velit eu, vulputate velit. Aliquam sed condimentum nisi.</a></h3>
    <div>
      <p>Vivamus dapibus tempor purus. Vivamus et sem id dui placerat elementum. Nunc tristique, lacus quis suscipit gravida, lacus nisi commodo magna, vitae tincidunt metus ex eu sem. Pellentesque et lobortis nunc, eget mattis nisl. Ut feugiat urna ac fringilla
        dictum. Mauris viverra hendrerit felis, sit amet convallis orci consectetur eu.</p>
    </div>

  </div>


  <!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

</body>

</html>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-03-05 02:30:17 +0000 UTC

为什么 .innerHTML 不起作用?

  • 2

我正在学习JS。为什么看似简单的替换段落文本的功能不起作用?错误在哪里?

window.onload = function() {
alert("Почему текст параграфов не меняется?");
  document.getElementsByTagName("p").innerHTML = "Test";
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Timer</title>


</head>

<body>
  <div id="accordion">
    <h1><a href=#>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a></h1>

    <h3><a href=#>Nulla non eleifend magna. Proin luctus ante ac felis blandit vestibulum.</a></h3>
    <div id="first">
      <p>Suspendisse potenti. Donec non venenatis lectus, sagittis faucibus est. Pellentesque lacinia ut odio nec semper. Maecenas eros massa, tristique ut nunc eget, fermentum tempor sapien. Vestibulum arcu leo, condimentum ut augue non, dapibus scelerisque
        dolor. Pellentesque pellentesque eget nisi at elementum. Etiam eu ante lacus. Etiam lacinia malesuada nisi a ullamcorper. Sed faucibus imperdiet elit, sed posuere tortor porttitor at. Curabitur nisi ante, rhoncus ut est nec, euismod elementum
        elit. Maecenas at condimentum lorem, ac posuere velit.</p>
    </div>

    <h3><a href=#>In dignissim, dui non euismod dictum, dolor dolor accumsan arcu, vel ornare elit velit at leo.</a></h3>
    <div>
      <p>Curabitur aliquam tellus non metus luctus, ac mattis lectus vehicula. Duis gravida facilisis sapien, facilisis sodales enim semper ut. Curabitur porta magna eu metus posuere, rutrum eleifend nulla imperdiet. Suspendisse a dui blandit, mattis augue
        et, ultricies diam. Phasellus tincidunt dui et orci bibendum, sit amet mollis nunc convallis. Duis ac ullamcorper tellus, a viverra ante.</p>
    </div>

    <h3><a href=#>Cras tincidunt leo non quam efficitur, eget scelerisque tortor tempor.</a></h3>
    <div>
      <p>Quisque elementum augue ac feugiat sodales. Nam auctor libero at semper aliquet. Nam convallis est nec nisl aliquet bibendum. Sed volutpat sed nisl nec laoreet. Donec dignissim felis a ipsum pellentesque ultrices. Integer vulputate tristique lectus
        quis venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed tempor nisl ipsum, at vestibulum nulla sagittis vitae. Phasellus at nunc ut odio dictum faucibus.</p>
    </div>

    <h3><a href=#>Ut ex nisl, ultrices vel sagittis bibendum, mollis efficitur ipsum.</a></h3>
    <div>
      <p>Aenean vitae lorem libero. Suspendisse venenatis, libero viverra aliquet facilisis, dui diam egestas nibh, at luctus augue est sit amet lorem. Phasellus non turpis vulputate, lacinia erat et, condimentum lorem. Curabitur ipsum sapien, interdum eget
        tincidunt at, placerat sed tellus. Nam purus orci, facilisis egestas porta sed, tempor id justo. Fusce elementum, diam sed fringilla congue, erat lectus pharetra purus, et ornare risus velit sit amet risus. Proin eu lorem odio. Nullam eu condimentum
        nibh.
      </p>
    </div>

    <h3><a href=#>Praesent quis lacus posuere, viverra velit eu, vulputate velit. Aliquam sed condimentum nisi.</a></h3>
    <div>
      <p>Vivamus dapibus tempor purus. Vivamus et sem id dui placerat elementum. Nunc tristique, lacus quis suscipit gravida, lacus nisi commodo magna, vitae tincidunt metus ex eu sem. Pellentesque et lobortis nunc, eget mattis nisl. Ut feugiat urna ac fringilla
        dictum. Mauris viverra hendrerit felis, sit amet convallis orci consectetur eu.</p>
    </div>

  </div>

</body>

</html>

javascript
  • 4 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-03-02 22:58:44 +0000 UTC

如何将方法分配给构造函数?

  • 1

我正在学习 JS,并注意到在创建一个对象后,您可以将外部函数作为其方法,而在赋值过程中会在对象内部创建一个新元素(用于存储函数)。如果我们想在构造函数中添加一个函数,我们只能将一个外部函数赋值给一个已经存在于构造函数中的元素。

问题是——有没有办法在构造函数中创建一个新元素(并为其赋值,就像函数一样)?

这是一个例子。如果我理解正确的话,它dog.newSound = changeSound;可以工作是因为它是一个对象,而animal.newSound = changeSound;不能工作是因为它是一个构造函数。有没有另一种方法可以为构造函数做同样的事情?

//Конструктор

function Animal(name, age, sound) {
  this.name = name;
  this.age = age;
  this.sound = sound;
}

//внешняя функция
function changeSound(sound) {
  this.sound = sound;
}

//объект созданный с помощью конструктора
var dog = new Animal("Jack", 5, "gav-gav")

//создали переменную в объекте и присвоили ей функцию
dog.newSound = changeSound;
dog.newSound("woof-woof"); // вызвали функцию 

//пишем на страницу
var here = document.getElementById("placeHere");
here.innerHTML = dog.sound;
<p id=placeHere></p>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-03-02 03:42:02 +0000 UTC

通过 setInterval() 调用函数后,一切都消失了

  • 2

有一个写一行的函数(document.write)。
它通过setInterval()调用。
为什么setInterval 会删除所有 HTML 元素而不是向它们添加文本?

var seconds = 1;

function repeatWrite(){
  document.write(seconds + " seconds left" + "<br>");
  seconds++
}

setInterval(repeatWrite, 1000);
<h1>Появляющийся текст!</h1>
<p>Каждую секунду ниже должен появляться текст</p>
<p>Но почему все эти HTML элементы исчезают?</p>

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-01-27 23:13:53 +0000 UTC

为什么 foreach 与数组、列表和字典的工作方式不同?[复制]

  • 2
这个问题已经在这里得到回答:
foreach 中使用 var 和 dynamic 的区别 (1 answer)
5 年前关闭。

我正在学习 C# 和 Unity。
问题 1:为什么将 foreach 与数组或列表一起使用,指定变量的类型和名称就足够了,但是对于字典 - 您需要使用 var 声明它(和子问题:我是 C# 新手,据我所知,变量通常是在没有 var 的情况下声明的)?
问题 2:为什么在使用字典时,可以不设置 foreach 循环变量的类型——它会自行确定,而在数组和列表的情况下——这是必要的吗?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestScript : MonoBehaviour {

    //Array
    string[] names = new string[]{"Name", "Surname"};

    //List
    List<string> animals = new List<string>(){"dog", "cat", "cow"};

    //Dictionary
    Dictionary<string,string> clothes = new Dictionary<string, string>();

    void Start () {
        clothes.Add("slot1", "hat");
        clothes.Add("slot2", "t-shirt");

        LoopTest();
    }

    void LoopTest(){

            //foreach loop goes through names array

            foreach (string name in names) {
                print (name);
            }

            //foreach loop goes through animals list

            foreach (string name in animals) {
                print (name);
            }


            //foreach loop goes through clothes dictionary

            foreach (var item in clothes) {
                print (item.Key + " " + item.Value);
            }

        }
}

它只是语法的一个特征,还是这里有某种逻辑?非常感谢!

c#
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-01-17 21:53:21 +0000 UTC

为什么图像超出链接区域

  • 0

我正在制作相册,我注意到一个有趣的效果:<div>背景图片在链接内部<a>,但它却在链接之外。将鼠标悬停在图像上可以看到这一点。

深入研究样式后,我意识到它在 中Bootstrap,但我还没有找到确切的内容。我将不胜感激。
提前致谢。

示例代码位于JSFiddle - https://jsfiddle.net/o7y4m1ut/那里一切正常。这里连接Bootstrap后的代码片段显示不正确。不明白为什么...

.ImgContainer {
  min-width: 100px;
  min-height: 150px;
  margin: 5px;
}

@media (min-width : 1200px) {
  .ImgContainer {
      margin: 0;
  }
}

.imgOne {
  background-image: url(http://blog.oxforddictionaries.com/wp-content/uploads/mountain-names.jpg);
  background-position: center;
  background-size: cover;
}

.gallery {
  display: block;
  /* border: dashed red 3px; */
  position: relative;
}

.gallery:hover {
  background-color: #555;
  text-decoration: none;
  color: white;
}

.myCol {
  min-height: 180px;
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section class="secionSecond">
<div class="container">
  <div class="row">

    <section class="col-md-4   col-lg-6  col-xs-12 col-sm-6 myCol firstCol">
      <a class="gallery gallerySix" href="#">
      <div class="row">
        <div class="col-lg-5 ImgContainer imgOne">

          <!-- <img src="img/summer-1.jpg" alt="There should be an image!"> -->
        </div>
        <div class="col-lg-7"><h3>Heading</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae sagittis ex.</p>
        </div>
      </div>
    </a>
    </section>

html
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-01-16 04:23:36 +0000 UTC

如何使 <li> 相对于 <ul> 边框居中?

  • 1

如何使列表的元素<li>围绕列表的边界居中<ul>?

ul {
  border: dashed blue 2px;
  list-style-position: inside;
  text-align: center;
}
li {
  border: dashed green 2px;
}
<ul>
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
</ul>

html
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-01-12 06:42:08 +0000 UTC

Bootstrap - 封面模板问题

  • 0

使用 Bootstrap 时遇到一个奇怪的问题。

有一个简单的页面,由两部分组成:
1.修改后的标准模板Cover(http://v4-alpha.getbootstrap.com/examples/cover/)2
.下面和section里面是标准行,列等。

Cover顶部 ( ) 和下面的部分之间有一个缩进。理论上 - 半透明body,虽然背景颜色不是白色而是灰色。

问题是我无法更改正文的背景颜色。
CSSbody显然只影响我看不到的封面后面的背景。
我通过控制台检查了它:奇怪 - 它body覆盖了整个页面(包括封面和部分),但是当您将鼠标悬停在控制台中的 body 上时,页面上只有该区域突出显示Cover,它们之间没有section空格。如果您将控制台悬停在section -section在页面上,它会被正确选择。

这里可能是什么问题?在此先感谢!

更新程序

看来我明白了原因: CSS shiblon Coversetshtml和body height="100%", в результате чего их высота становится равна размеру окна браузера. Не совсем понимаю, почему в таком случае, фоновый цветbody`在整个文档中发生了变化?..

但主要问题是如何用body另一种元素代替?随着页面在下方继续,body它不应限于Cover. 我试图附上Cover并div问他同样的那些CSS,body但它不起作用。

这是代码(在 jsfiddle 上显示更正确): https ://jsfiddle.net/x3ju0d9w/

/*
 * Globals
 */

/* Links */

a,
a:focus,
a:hover {
  color: #fff;
}
/* Custom default button */

.btn-secondary,
.btn-secondary:hover,
.btn-secondary:focus {
  color: #333;
  text-shadow: none;
  /* Prevent inheritance from `body` */
  background-color: #fff;
  border: .05rem solid #fff;
}
/*
 * Base structure
 */

html,
body {
  height: 100%;
  background-color: #333;
}
body {
  color: #fff;
  text-align: center;
  text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5);
}
/* Extra markup and styles for table-esque vertical and horizontal centering */

.site-wrapper {
  display: table;
  width: 100%;
  height: 100%;
  /* For at least Firefox */
  min-height: 100%;
  -webkit-box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
  box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
}
.site-wrapper-inner {
  display: table-cell;
  vertical-align: top;
}
.cover-container {
  margin-right: auto;
  margin-left: auto;
}
/* Padding for spacing */

.inner {
  padding: 2rem;
}
/*
 * Header
 */

.masthead {
  margin-bottom: 2rem;
}
.masthead-brand {
  margin-bottom: 0;
}
.nav-masthead .nav-link {
  padding: .25rem 0;
  font-weight: bold;
  color: rgba(255, 255, 255, .5);
  background-color: transparent;
  border-bottom: .25rem solid transparent;
}
.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus {
  border-bottom-color: rgba(255, 255, 255, .25);
}
.nav-masthead .nav-link + .nav-link {
  margin-left: 1rem;
}
.nav-masthead .active {
  color: #fff;
  border-bottom-color: #fff;
}
@media (min-width: 48em) {
  .masthead-brand {
    float: left;
  }
  .nav-masthead {
    float: right;
  }
}
/*
 * Cover
 */

.cover {
  padding: 0 1.5rem;
}
.cover .btn-lg {
  padding: .75rem 1.25rem;
  font-weight: bold;
}
/*
 * Footer
 */

.mastfoot {
  color: rgba(255, 255, 255, .5);
}
/*
 * Affix and center
 */

@media (min-width: 40em) {
  /* Pull out the header and footer */
  .masthead {
    position: fixed;
    top: 0;
  }
  .mastfoot {
    position: fixed;
    bottom: 0;
  }
  /* Start the vertical centering */
  .site-wrapper-inner {
    vertical-align: middle;
  }
  /* Handle the widths */
  .masthead,
  .mastfoot,
  .cover-container {
    width: 100%;
    /* Must be percentage or pixels for horizontal alignment */
  }
}
@media (min-width: 62em) {
  .masthead,
  .mastfoot,
  .cover-container {
    width: 42rem;
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />



<div class="site-wrapper">

  <div class="site-wrapper-inner">

    <div class="cover-container">

      <div class="masthead clearfix">
        <div class="inner">
          <h3 class="masthead-brand">Cover</h3>
          <nav class="nav nav-masthead">
            <a class="nav-link active" href="#">Home</a>
            <a class="nav-link" href="#">Features</a>
            <a class="nav-link" href="#">Contact</a>
          </nav>
        </div>
      </div>

      <div class="inner cover">
        <h1 class="cover-heading">Cover your page.</h1>
        <p class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.</p>
        <p class="lead">
          <a href="#" class="btn btn-lg btn-secondary">Learn more</a>
        </p>
      </div>

      <div class="mastfoot">
        <div class="inner">
          <p>Cover template for <a href="https://getbootstrap.com">Bootstrap</a>, by <a href="https://twitter.com/mdo">@mdo</a>.</p>
        </div>
      </div>

    </div>

  </div>

</div>
</section>
<section class="sectionSecond">
  <div class="container">
    <div class="row">
      <div class="col-md-3">
        <h1>Column-left</h1>
      </div>
      <div class="col-md-6">
        <h1>Column-middle</h1>
      </div>
      <div class="col-md-3">
        <h1>Column-right</h1>
      </div>
    </div>
  </div>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

再次提前致谢!

html
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-09-30 22:13:06 +0000 UTC

什么是开发支持,

  • 1

开发支持是什么意思?该术语是否包括前端和后端网站以及移动应用程序或其他内容?请帮我理解这个词的意思。

терминология
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-09-03 03:02:13 +0000 UTC

执行刚刚运行的代码时出错(JSON.parse:意外字符)

  • 0

我正在掌握一种将内容(文本)从 json 文件加载到网页上的方法。放置在页面上之前的内容是使用 handlebars 模板编译的。具有所有这些逻辑的 javascript 文件被编写为使用 browserify 编译的 commonjs 模块。我正在使用安装了 NodeJS npm 的本地 http 服务器运行该页面。

测试用例有效,当尝试将此方法应用于完成的网页时,出现了问题。由于我刚刚学习这种方法,我将不胜感激。

所以有:

  • webContent.json - 它存储将加载到index.html中的内容(文本)
  • contentProcess.js - 包含一个向webContent.json发送 Ajax 请求、解析、编译Handlebars Template并将内容放在页面上的函数(使用 innerHTML)
  • addContent.js - 从contentProcess.js调用函数,替换必要的变量。contentProcess.js和 addContent.jscommonjs作为模块编写和捆绑。然后将它们编译到main.js中browserify。
  • index.html - 包含Handlebars Template, div, 将放置内容和指向main.js的链接

测试版有效。当我试图用一个已经存在的网页实现这种方法时,有些东西不起作用。控制台抱怨来自main.js的一段逻辑,它最初是 contentProcess.js中函数的一部分,在测试用例中没有问题(下面的两个屏幕截图): 在此处输入图像描述

在此处输入图像描述 这里有什么问题(在测试版本中这个功能有效)?

在剪辑中,我分散了上述所有文件的代码片段(由注释分隔):

/* --- webContent.json --- */
{
header: "Powerful business", 
describtion: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec turpis neque, sodales a faucibus at, viverra luctus urna. Suspendisse dignissim neque dui, in tincidunt arcu.'
}


/* --- contentProcess.js --- */

module.exports = function(jsonDir, templId, finId){
function sendGet(callback) {
    /* create an AJAX request using XMLHttpRequest*/
    var xhr = new XMLHttpRequest();
    /*reference json url taken from: http://www.jsontest.com/*/

    /* Specify the type of request by using XMLHttpRequest "open", 
       here 'GET'(argument one) refers to request type
       "http://date.jsontest.com/" (argument two) refers to JSON file location*/
    xhr.open('GET', jsonDir);

    /*Using onload event handler you can check status of your request*/
    xhr.onload = function () {
        if (xhr.status === 200) {
            callback(JSON.parse(xhr.responseText));
        } else {
            alert(xhr.statusText);
        }
    };

    /*Using onerror event handler you can check error state, if your request failed to get the data*/
    xhr.onerror = function () {
        alert("Network Error");
    };

    /*send the request to server*/
    xhr.send();
}

//For template-1
var dateTemplate = document.getElementById(templId).innerHTML;
var template = Handlebars.compile(dateTemplate);

sendGet(function (response) {
    document.getElementById(finId).innerHTML += template(response);
})
}


/* --- addContent.js --- */
var addContent = require('./contentProcess');
addContent("../data/webContent.json", "main-template", 'maintext');
/* --- main.js (после компиляции addContent.js с помощью browserify) --- */

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var addContent = require('./contentProcess');

/*MAINBLOCK*/ 
addContent("../data/webContent.json", "main-template", 'maintext');
},{"./contentProcess":2}],2:[function(require,module,exports){

module.exports = function(jsonDir, templId, finId){
function sendGet(callback) {
    /* create an AJAX request using XMLHttpRequest*/
    var xhr = new XMLHttpRequest();
    /*reference json url taken from: http://www.jsontest.com/*/

    /* Specify the type of request by using XMLHttpRequest "open", 
       here 'GET'(argument one) refers to request type
       "http://date.jsontest.com/" (argument two) refers to JSON file location*/
    xhr.open('GET', jsonDir);

    /*Using onload event handler you can check status of your request*/
    xhr.onload = function () {
        if (xhr.status === 200) {
            callback(JSON.parse(xhr.responseText));
        } else {
            alert(xhr.statusText);
        }
    };

    /*Using onerror event handler you can check error state, if your request failed to get the data*/
    xhr.onerror = function () {
        alert("Network Error");
    };

    /*send the request to server*/
    xhr.send();
}

//For template-1
var dateTemplate = document.getElementById(templId).innerHTML;
var template = Handlebars.compile(dateTemplate);

sendGet(function (response) {
    document.getElementById(finId).innerHTML += template(response);
})
}



},{}]},{},[1]);
<!-- фрагмент кода из index.html (на странице используется bootstrap, если это имеет значение) -->

<div id="maintext"> </div>
                     <script id="main-template" type="text/x-handlebars-template">
                    {{{header}}} {{{describtion}}} {{{sentence3}}}
                     </script>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-08-22 10:28:12 +0000 UTC

如何在div(flex)中居中并对齐到div的右边缘

  • 1

有一个div,里面有几个小div。您需要将它们垂直居中并将它们按到右边缘。

以display: flex; 我现在如何将它们推到右边为中心?margin-left: auto;div 之间的填充,我需要将它们推到右边缘而不在它们之间填充。

html
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-08-20 01:55:35 +0000 UTC

车把,javascript。使用内容创建新变量时,一切都停止工作[关闭]

  • 1
关闭 这个问题是题外话。目前不接受回复。

问题是一个不再复现的issue,或者错别字引起的。虽然类似的问题可能与此站点相关,但此问题的解决方案不太可能对未来的访问者有所帮助。像这样的问题通常可以通过编写和研究一个最小的程序来避免,在发布问题之前重现问题。

6 年前关闭。

改进问题

我正在使用 Handlebars 从 Javascript 文件加载 HTML 内容。下面是将文本放入 HTML div 中的代码。

var mainInfo = "{{{header}}} {{{describtion}}}  {{{sentence3}}}";
var template = Handlebars.compile(mainInfo);
var data = template({
    header: "<h1>Powerful business</h1>", 
    describtion: '<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit.Donec turpis neque, sodales a faucibus at, viverra luctus urna. Suspendisse dignissim neque dui, in tincidunt arcu.</p>'
});

document.getElementById ("maintext").innerHTML += data;

但是当我用不同的变量名复制相同的代码以便以相同的方式加载网页其他区域的内容时,一切都停止了。

根据经验,我意识到仍然可以创建一个新变量,但值得为其分配一个 handlebars 表达式,例如:

 var cerviceContent = "{{newheader}}} {{{content}}};

文本从各处消失。为什么以及如何解决它?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-08-17 03:54:15 +0000 UTC

如何使用引导程序对徽标进行绝对定位?

  • 1

如何使用引导程序对徽标进行绝对定位?

徽标与导航菜单位于同一容器中。容器会有背景图片,容器需要和菜单一样高,不包括徽标的高度。

在此处输入图像描述

  <nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">

        <a href="#" class="pull-left"><img src="img/Logo.png"></a> <!--Логотип -->

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>

    </div>
    <div id="navbar" class="collapse navbar-collapse pull-right">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#contact">Services</a></li>
          <li><a href="#contact">Portfolio</a></li>
          <li><a href="#contact">Blog</a></li>
          <li><a href="#contact">Contact</a></li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>
html
  • 1 个回答
  • 10 Views
Martin Hope
Rumata
Asked: 2020-08-13 07:40:16 +0000 UTC

如何在 json 文件命令中为控制台执行两个连续的命令?

  • 1

如何将控制台的两个连续命令添加到 json 文件?

我正在学习node.js 和 NPM,我有一个“服务器”文件夹,其中安装了http 服务器和package.json文件,其中有一个带有网页的“webdir”文件夹。

我可以手动启动 Web 服务器,或者通过使用命令指定它的路径node [путь до файла, запускающего сервер],但我需要使用命令自动启动它npm start。它应该从“webdir”文件夹启动,这样我就可以立即访问我的网页localhost:8080。

为此,我需要在控制台中连续写入两个命令:
1. cd webdir
2. node [启动 Web 服务器的文件的路径]

json文件中的语法应该是什么,以便命令在控制台中顺序输入并执行这两行?

这是一行的工作代码:

"scripts": {
    "start": "node (...)/node_modules/http-server/bin/http-server"
  },
javascript
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5